A Promise that can be explicitly resolved or rejected.

Type Parameters

  • T = any

Hierarchy

  • CompletablePromise

Constructors

Properties

deferredPromise: DeferredPromise<T>
promise: Promise<T>
state: State = State.Pending

Methods

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

    Type Parameters

    • TResult = never

    Parameters

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

      The callback to execute when the Promise is rejected.

    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

    • Optional onfinally: null | (() => void)

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

    Returns Promise<T>

    A Promise for the completion of the callback.

  • Returns the inner Promise instance.

    Returns Promise<T>

    The inner Promise instance.

  • Rejects the Promise with a provided reason or error. This method call will succeed only if the Promise state was Pending, and it will irreversibly change the Promise state to Rejected.

    Parameters

    • reason: any

      The reason or error.

    Returns void

  • Resolves the Promise with a value or the result of another Promise. This method call will succeed only if the Promise state was Pending, and it will irreversibly change the Promise state to Fulfilled.

    Parameters

    • value: T | PromiseLike<T>

      The value or the result of another Promise.

    Returns void

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

    Type Parameters

    • TResult1 = T

    • TResult2 = never

    Parameters

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

      The callback to execute when the Promise is resolved.

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

      The callback to execute when the Promise is rejected.

    Returns Promise<TResult1 | TResult2>

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

  • Attempts to resolve the Promise with a value or the result of another Promise. If retrieving {@param getValue} result fails, reject function will be called instead.

    Parameters

    • getValue: (() => T | PromiseLike<T>)

      A function that returns the value or the result of another Promise.

        • (): T | PromiseLike<T>
        • Returns T | PromiseLike<T>

    Returns void

Generated using TypeDoc