Wrapper of global.Promise class. Read more about Promises.

Type Parameters

  • T

Hierarchy (view full)

Implements

  • Promise<T>

Constructors

  • Creates Promise instances.

    Type Parameters

    • T

    Parameters

    • executor: ((resolve, reject) => void)

      defined as (resolve,reject)=> {}

        • (resolve, reject): void
        • Parameters

          • resolve: ((value) => void)
              • (value): void
              • Parameters

                • value: T | PromiseLike<T>

                Returns void

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

                • Optional reason: any

                Returns void

          Returns void

    Returns ExtendedPromise<T>

    Example

    new Promise((resolve,reject)=>{
    ...
    });
  • Internal constructor. Do not call.

    Type Parameters

    • T

    Parameters

    • promise: PromiseLike<T> | LegacyDojoDeferred
    • state: undefined | State
    • tag: typeof PRIVATE_CONSTUCTOR_TAG

    Returns ExtendedPromise<T>

Methods

  • Creates promise which fulfills if all other promises are fulfilled. Or rejects if one of the promises rejects.

    Type Parameters

    • T extends [] | readonly unknown[]

    Parameters

    • iterable: T

      Iterable of Promise instances

    Returns ExtendedPromise<{
        -readonly [P in string | number | symbol]: Awaited<T[P]>
    }>

  • Creates a promise that resolves after all of the given promises have either fulfilled or rejected, with an array of objects that each describes the outcome of each promise.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T | PromiseLike<T>>

      Iterable of Promise instances

    Returns ExtendedPromise<PromiseSettledResult<Awaited<T>>[]>

  • Promise.any() takes an iterable of Promise objects and, as soon as one of the promises in the iterable fulfills, returns a single promise that resolves with the value from that promise. If no promises in the iterable fulfill (if all of the given promises are rejected), then the returned promise is rejected with an AggregateError, Essentially, this method is the opposite of Promise.all().

    Type Parameters

    • T

    Parameters

    • iterable: (T | PromiseLike<T>)[] | Iterable<T | PromiseLike<T>>

      Iterable of Promise instances

    Returns ExtendedPromise<T>

  • This method tests if a given object is a promise. The algorithm will return true for:

    • apprt-core/Promise
    • global Promise
    • dojo/Deferred
    • dojo/Deferred.promise

    Note: Because of support for dojo/Deferred any object with a 'then', 'isResolved' and 'isRejected' method is detected as a promise.

    Parameters

    • candidate: any

      a potential promise.

    Returns candidate is PromiseLike<unknown>

    true if candidate is a promise.

  • Creates promise which fulfills if one of the other promises fulfills. Or rejects if one of the promises rejects.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>

      Iterable of Promise instances

    Returns ExtendedPromise<T extends PromiseLike<U>
        ? U
        : T>

  • Creates promise which fulfills if one of the other promises fulfills. Or rejects if one of the promises rejects.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T | PromiseLike<T>>

      Iterable of Promise instances

    Returns ExtendedPromise<T>

  • Type Parameters

    • T = never

    Parameters

    • Optional reason: any

      The reason the promise was rejected.

    Returns ExtendedPromise<T>

    a promise in rejected state.

  • Creates a new resolved promise

    Returns ExtendedPromise<void>

  • Creates a new resolved promise with the given value

    Type Parameters

    • T

    Parameters

    • value: T

      result object.

    Returns ExtendedPromise<T>

    a promise in fulfilled state.

  • Produces an object with a promise along with its resolution and rejection functions. Allows to resolve/reject the promise manually after creating it.

    Type Parameters

    • T

    Returns {
        promise: ExtendedPromise<T>;
        reject: ((reason?) => void);
        resolve: ((value) => void);
    }

    • promise: ExtendedPromise<T>
    • reject: ((reason?) => void)
        • (reason?): void
        • Parameters

          • Optional reason: unknown

          Returns void

    • resolve: ((value) => void)
        • (value): void
        • Parameters

          • value: T | PromiseLike<T>

          Returns void

    Example

    const { promise, resolve, reject } = Promise.withResolvers();
    
  • Wraps e.g. dojo/Deferred or native Promise to this Promise class.

    Type Parameters

    • T

    Parameters

    • promise: LegacyDojoDeferred | PromiseLike<T>

    Returns ExtendedPromise<T>

    a promise

  • Registers an error handler. Which is not called if the error is a Cancel instance.

    Type Parameters

    • TResult = never

    Parameters

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

      called when the promise rejects

    Returns ExtendedPromise<T | TResult>

  • Registers a handler, which is called in success or error state. But the handler is not able to change the result state!

    Parameters

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

      function invoked regardless of success or error

    Returns ExtendedPromise<T>

Generated using TypeDoc