Function
allSettled (entries, label) Promise public
Module: | rsvp |
---|
Defined in node_modules/rsvp/lib/rsvp/all-settled.js:20
import { allSettled } from 'rsvp';
- entries
- Array
- label
- String
- - optional string that describes the promise. Useful for tooling.
- returns
- Promise
- promise that is fulfilled with an array of the settled states of the constituent promises.
RSVP.allSettled
is similar to RSVP.all
, but instead of implementing a fail-fast method, it waits until all the promises have returned and shows you all the results. This is useful if you want to handle multiple promises' failure states together as a set.
Returns a promise that is fulfilled when all the given promises have been settled. The return promise is fulfilled with an array of the states of the promises passed into the promises
array argument.
Each state object will either indicate fulfillment or rejection, and provide the corresponding value or reason. The states will take one of the following formats:
{ state: 'fulfilled', value: value } or { state: 'rejected', reason: reason }
Example:
let promise1 = RSVP.Promise.resolve(1); let promise2 = RSVP.Promise.reject(new Error('2')); let promise3 = RSVP.Promise.reject(new Error('3')); let promises = [ promise1, promise2, promise3 ]; RSVP.allSettled(promises).then(function(array){ // array == [ // { state: 'fulfilled', value: 1 }, // { state: 'rejected', reason: Error }, // { state: 'rejected', reason: Error } // ] // Note that for the second item, reason.message will be '2', and for the // third item, reason.message will be '3'. }, function(error) { // Not run. (This block would only be called if allSettled had failed, // for instance if passed an incorrect argument type.) });
© 2020 Yehuda Katz, Tom Dale and Ember.js contributors
Licensed under the MIT License.
https://api.emberjs.com/ember/3.25/functions/rsvp/allSettled