Class CancelableAsyncFlow<ARGS, RET, PROGRESS>

The CancelableAsyncFlow wraps a generator function and allows progress through the generator to be observed. Furthermore, it provides cancellation facilities to abort the generator execution early. ProgressObserver

Type Parameters

  • ARGS extends []

  • RET

  • PROGRESS

Hierarchy

  • CancelableAsyncFlow

Constructors

Methods

Constructors

  • Type Parameters

    • ARGS extends []

    • RET

    • PROGRESS

    Parameters

    • generatorFactory: ((abortSignal: AbortSignal, ...args: ARGS) => AsyncGenerator<PROGRESS, RET, never>)

      This generator factory will be used by the CancelableAsyncFlow to generate AsyncGenerators.

        • (abortSignal: AbortSignal, ...args: ARGS): AsyncGenerator<PROGRESS, RET, never>
        • Parameters

          • abortSignal: AbortSignal
          • Rest ...args: ARGS

          Returns AsyncGenerator<PROGRESS, RET, never>

    Returns CancelableAsyncFlow<ARGS, RET, PROGRESS>

Methods

  • This function constructs an AsyncGenerator using the generatorFactory from the constructor.

    Returns

    A promise that completes once the generator has finished its execution. It will contain the last return value of the generator function.

    Parameters

    • abortSignal: AbortSignal

      This abort signal can be used to interrupt the generator between two stages.

    • progressObserver: ProgressObserver<PROGRESS>

      The progress observer is passed to the generator as its first argument.

    • Rest ...args: ARGS

      Custom arguments to pass to the generator function.

    Returns Promise<RET>

Generated using TypeDoc