A "promise" that may be canceled.

Behaviors like a normal promise but does not actually extend Promise because that makes extension a PITA.

Type Parameters

  • T = void

Hierarchy (view full)

Implements

  • Promise<T>

Constructors

Accessors

Methods

Constructors

  • Type Parameters

    • T = void

    Parameters

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

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

                • value: T | PromiseLike<T>

                Returns void

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

                • Optionalreason: any

                Returns void

          Returns void

    • OptionalonCancel: (() => void)
        • (): void
        • Returns void

    Returns CancelablePromise<T>

Accessors

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

Methods

  • Returns void

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

    Type Parameters

    • TResult = never

    Parameters

    • Optionalonrejected: null | ((reason: any) => TResult | PromiseLike<TResult>)

      The callback to execute when the Promise is rejected.

    Returns CancelablePromise<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)

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

    Returns CancelablePromise<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

    • Optionalonfulfilled: null | ((value: T) => TResult1 | PromiseLike<TResult1>)

      The callback to execute when the Promise is resolved.

    • Optionalonrejected: null | ((reason: any) => TResult2 | PromiseLike<TResult2>)

      The callback to execute when the Promise is rejected.

    Returns CancelablePromise<TResult1 | TResult2>

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