operation function

Module @runic-artifex/views-effect in @runic-artifex/views-effect 0.23.0

function operation<T, F = never>(start: (requestId: string) => PromiseLike<BridgeOperation<T, F>>, options: RetryOperationOptions): Effect.Effect<T, ViewOperationError | ViewDomainFailureOf<F>>;
function operation<T, F = never>(start: () => PromiseLike<BridgeOperation<T, F>>, options?: OperationOptions): Effect.Effect<T, ViewOperationError | ViewDomainFailureOf<F>>;

Starts a .NET operation and waits for its terminal status. When the Effect ends without a terminal status, because it was interrupted (including by Effect.timeout or between retries), timed out, or failed to observe the operation after its last attempt, it sends the cancellation request for the operation it started before it completes. The start request itself is not interruptible: an interruption waits for .NET to answer it, so an admitted operation is never left running unobserved. Retrying is only offered with an explicit request ID, which makes a repeated start return the operation already running instead of starting another. Between attempts the operation keeps running:

yield* operation(() => editor.startSave(), { timeout: "10 seconds" });
yield* operation(id => editor.startSave({ requestId: id }), {
  requestId: crypto.randomUUID(),
  retry: Schedule.exponential("200 millis").pipe(Schedule.take(3)),
});