Answer the question
In order to leave comments, you need to log in
Do I understand the work of Promise.all correctly?
Option 1
Option 2
[1,2,3,4,5].map(num => heavyIOfunction);
Promise.all([1,2,3,4,5].map(num => heavyIOfunction));
Answer the question
In order to leave comments, you need to log in
Do I understand correctly that there is no difference between the two options and IO operations start to be executed in parallel from the heavyIOfunction call itself, and not from Promise.all?
Promise.all only registers a promise on the result of calling all IO operations.
await Promise.all(arrOfPromises);
await arrOfPromises.reduce(async (acc, promise) => {
await acc;
return promise;
}, Promise.resolve());
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question