Hacker News new | ask | show | jobs
by wa1987 1630 days ago
What's the pros/cons vs Promise.all([...])?
1 comments

> Assuming the first request is done much faster than the second request, we can already utilize the CPU and doSomeCalculation while waiting for the second request to finish. In this case, the shown code is better than Promise.all([request1, request2]).

    Promise.all([request1.then(doSomeWork), request2])

?
yes this would work. It's just nested.
The nesting has the advantage of directly expressing the dependency structure of the promises, which is otherwise a bit hard to infer.