Promise all method for a collection of promises
When a whole bunch of tasks need to be accomplished before moving on with things, some or all of which might take a while, one way to do so is with the Promise.all method. This method will return a resolved promise object when everything that is given to it via an array as the first argument is resolved if a promise, or is something that is not a promise. In Other words the promise all method will only resolve when every element in a given array is a value, or a promise object that has been resolve, rather than rejected. The Promise all method will then only result in a rejected promise if one or more promise in the array reject. So then the array that is given to the promise all method can be a mixed collection of values, some of which can be promises, and things will not continue until all promises in the array are resolved or rejected.
So it goes without saying that the promise all method is fairly useful whenever I am in a situation in which I need to do a whole bunch of async tasks, and then continue with more to do once all of that has completed. The promise all method should be there when it comes to native Promise support, but can also be added when working with older platforms via something like bluebird.
So then lets take a look at a few examples of the promise all method in action.