Function buildCancellablePromise

  • Used to build a single [[CancellablePromise]] from a multi-step asynchronous flow.

    When the overall promise is canceled, each captured promise is canceled. In practice, this means the active asynchronous operation is canceled.

    function query(id: number): CancellablePromise<QueryResult> {
    return buildCancellablePromise(async capture => {
    const result1 = await capture(api.method1(id))

    // do some stuff

    const result2 = await capture(api.method2(result1.id))

    return { result1, result2 }
    })
    }

    Type Parameters

    • T

    Parameters

    Returns CancellablePromise<T>

Generated using TypeDoc