DEV Community

Cover image for 🚀 [GIF] Cheatsheet for Javascript Promise API methods - Promise.all, Promise.allSettled, Promise.race, Promise.any

🚀 [GIF] Cheatsheet for Javascript Promise API methods - Promise.all, Promise.allSettled, Promise.race, Promise.any

Hem on January 13, 2020

Hello everybody 👋! I created this GIF cheatsheet for my own reference and I hope it will be useful for the community as well ❤️ Index ...
Collapse
 
midasxiv profile image
Midas/XIV

Love the gifs 😁. Good job.

Collapse
 
hem profile image
Hem

Thanks a lot @Midas/XIV ! This motivates me to create more

Collapse
 
mtbisu profile image
Nguyễn Mạnh Thắng

Anyone can response this one. In promise all. When one of them is rejected. The result will immediately go to catch block or wait to the result of the rest children promises and go to catch block after? Thanks

Collapse
 
hem profile image
Hem • Edited

When one of the promises in the input array (or iterable) get rejected, Promise.all rejects as well. Refer the attached snippet.

One thing to note here is that just because Promise.all short-circuited, it doesn't, in any way, affect the execution of other passed-in promises. They just execute independently (See how P3 promise executes independently even though P2 had already rejected and short-circuited Promise.all)

Snippet : Link

Collapse
 
mtbisu profile image
Nguyễn Mạnh Thắng

Thanks. Your answer helps me a lot indeed :)

Collapse
 
amineamami profile image
amineamami

Well done, i prefer RxJS observables tho

Collapse
 
diek profile image
diek

Lovely! Thank you!

Collapse
 
hem profile image
Hem

My Pleasure!

Collapse
 
saulsilver profile image
Hatem Houssein

Great job at the visualization! 🎉

Collapse
 
maprangsoft profile image
Maprangsoft

i love this article thank you.

Collapse
 
zingxy profile image
zing

Amazing!

Collapse
 
superpugn0 profile image
Mattia Ruberto

Awesome! Amazing! Thank you so much!