Slide 32
Slide 32 text
RISTEK Fasilkom Universitas Indonesia 2023 | 32
Promise.all vs Multiple Await
● Fail fast, eg
○ We have two independent async parallel tasks and the first one takes a very long time to
resolve but the second is rejected in a very short time, why leave the user to wait for the
longer call to finish to receive an error message?
● Error handling, eg
○ Managing error handling for multiple asynchronous tasks running in parallel can be
challenging, especially when using several 'await' calls. In a less than ideal situation, you're
likely to encounter warnings like 'UnhandledPromiseRejectionWarning' and
'PromiseRejectionHandledWarning', irrespective of your try/catch block placement. This is
the primary reason behind the creation of Promise.all, which is designed to effectively
handle such scenarios.
Codepen: Some example of how Promise All