3 ms·
> 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 requ
by WolfOliver 5y ago
> 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]).
- duped 5y agoPromise.all([request1.then(doSomeWork), request2]) ?
- WolfOliver 5y agoyes this would work. It's just nested.
- Footkerchief 5y agoThe nesting has the advantage of directly expressing the dependency structure of the promises, which is otherwise a bit hard to infer.