Deferred promise implementation.

Type Parameters

  • T

Hierarchy

  • DeferredPromise

Implements

  • Promise<T>

Constructors

  • Create a new deferrable promise which supports resolving it outside of the context of the promise.

    Type Parameters

    • T

    Parameters

    • Optional promise: Promise<T>

      Optionally a promise to wrap.

    Returns DeferredPromise<T>

Properties

#innerPromise: Promise<T>
#isResolved: boolean = false
#reject: ((err) => void)

Type declaration

    • (err): void
    • Parameters

      • err: any

      Returns void

#resolve: ((result) => void)

Type declaration

    • (result): void
    • Parameters

      • result: T | Promise<T>

      Returns void

Accessors

Methods

  • Bind the current promise to another promise, resolving or rejecting the current promise when the other promise is resolved or rejected.

    Parameters

    • other: Promise<T>

      The other promise to bind to.

    Returns DeferredPromise<T>

    The current promise.

  • Type Parameters

    • TResult = never

    Parameters

    • Optional onrejected: ((reason) => TResult | PromiseLike<TResult>)
        • (reason): TResult | PromiseLike<TResult>
        • Parameters

          • reason: any

          Returns TResult | PromiseLike<TResult>

    Returns Promise<T | TResult>

  • Parameters

    • Optional onFinally: (() => void)
        • (): void
        • Returns void

    Returns Promise<T>

  • Type Parameters

    • TResult1 = T

    • TResult2 = never

    Parameters

    • Optional onfulfilled: ((value) => TResult1 | PromiseLike<TResult1>)
        • (value): TResult1 | PromiseLike<TResult1>
        • Parameters

          • value: T

          Returns TResult1 | PromiseLike<TResult1>

    • Optional onrejected: ((reason) => TResult2 | PromiseLike<TResult2>)
        • (reason): TResult2 | PromiseLike<TResult2>
        • Parameters

          • reason: any

          Returns TResult2 | PromiseLike<TResult2>

    Returns Promise<TResult1 | TResult2>