Class CancelablePromise<T>

Type Parameters

  • T

Implements

  • Promise<T>

Accessors

  • get [toStringTag](): string
  • Returns string

  • get isCancelled(): boolean
  • Returns boolean

Constructors

  • Type Parameters

    • T

    Parameters

    • executor: ((resolve: ((value: T | PromiseLike<T>) => void), reject: ((reason?: unknown) => void), onCancel: OnCancel) => void)
        • (resolve, reject, onCancel): void
        • Parameters

          • resolve: ((value: T | PromiseLike<T>) => void)
              • (value): void
              • Parameters

                • value: T | PromiseLike<T>

                Returns void

          • reject: ((reason?: unknown) => void)
              • (reason?): void
              • Parameters

                • Optionalreason: unknown

                Returns void

          • onCancel: OnCancel

          Returns void

    Returns CancelablePromise<T>

Methods

  • Returns void

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

    Type Parameters

    • TResult = never

    Parameters

    • OptionalonRejected: null | ((reason: unknown) => TResult | PromiseLike<TResult>)

    Returns Promise<T | TResult>

    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 | (() => void)

    Returns Promise<T>

    A Promise for the completion of the callback.

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

    Type Parameters

    • TResult1 = T
    • TResult2 = never

    Parameters

    Returns Promise<TResult1 | TResult2>

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

Properties

cancelHandlers: (() => void)[]
promise: Promise<T>