Class CancellablePromise<T>

A cancellable Promise, taking a cancellation function returning executor. Cancellation can be triggered through the cancel method, or by an AbortSignal.

Type Parameters

  • T

Hierarchy (view full)

Constructors

Accessors

Methods

Constructors

Accessors

Methods

  • Attaches a callback for only the rejection of the Promise.

    Type Parameters

    • TF = never

    Parameters

    • Optionalonrejected: null | Callable<unknown, TF | PromiseLike<TF>>

      The callback to execute when the Promise is rejected.

    Returns Promise<T | TF>

    A Promise for the completion of the callback.

  • Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The resolved value cannot be modified from the callback.

    Parameters

    • Optionalonfinally: null | Callable

      The callback to execute when the Promise is settled (fulfilled or rejected).

    Returns Promise<T>

    A Promise for the completion of the callback.

  • Attaches callbacks for the resolution and/or rejection of the Promise.

    Type Parameters

    • TS = T
    • TF = never

    Parameters

    • Optionalonfulfilled: null | Callable<T, TS | PromiseLike<TS>>

      The callback to execute when the Promise is resolved.

    • Optionalonrejected: null | Callable<unknown, TF | PromiseLike<TF>>

      The callback to execute when the Promise is rejected.

    Returns Promise<TS | TF>

    A Promise for the completion of which ever callback is executed.