Magek Framework
    Preparing search index...

    Class Promises

    Index

    Constructors

    Methods

    • Waits until all the passed promise-like values are settled, no matter if they were fulfilled or rejected. If some rejected were found, an array with all the rejected promises is thrown. If all were fulfilled, an array of PromiseFulfilledResult is returned

      Type Parameters

      • TValue

      Parameters

      • values: Iterable<TValue>

        Array of promise-like values to be wait for

      Returns Promise<PromiseSettledResult<unknown>[]>

      an array of PromiseRejectedResult with all the rejected promises, if any

      Comparison with other similar Promise methods:

      • Promise.all: This has an "all-or-nothing" behavior. As long as one of the promises is rejected, the result is rejected. More importantly, it does not wait for al the promises to finish, which could lead to undesired behaviors
      • Promise.allSettled: This method waits for all the promises to finish and then returns an array of results. Some of them will be fulfilled and some rejected. More importantly, it never throws an error, which could lead to unexpected consequences. For example if you do "await Promise.allSettle(...)" expecting it to throw if some of them failed, you won't get that.

      In brief, Promises.allSettledAndFulfilled behaves exactly the same way as Promise.allSettle but it throws with an array of the failed promises, only if there are any.