DEV Community

Promises in 15 minutes

Mariane Santana on May 05, 2020

Good evening, fellows! Let's simplify the use of Promises? Particularly, when I started with the concept of Promises when I learned how to code, ...
Collapse
 
jamesthomson profile image
James Thomson

Just be careful with Promise.all, if one promise fails, then all are considered rejected. IMO, using Promise.allSettled is a better approach - but also a much newer method.

Collapse
 
marianesantana profile image
Mariane Santana

Thanks for the tip, never have I ever use Promise.allSettled. But I'm working in part 2 with more details about Promises. ;)

Collapse
 
mikkodc profile image
mikkodc

Great tip as well! I never knew that this existed, thanks. I'm just starting out on the new ES version

Collapse
 
fluffynuts profile image
Davyd McColl

Good post! If anyone is interested, I wrote an interactive promises post long ago here: davydm.blogspot.com/2015/07/callba...

It gives some insight into promise usage and interoperability - different promise implementations (native, jQuery, q, bluebird, others) work together because of duck-typing - as well as a look at building your own implementation. I've built my own implementation of promises more than once - mostly for interest, but twice (re-coded from scratch when the architecture made fixing a particular bug near impossible) for synchronous-promise, an implementation of promises which doesn't background, on purpose, originally to make async testing easier, but it turns out people have found other uses for it.

I've been meaning to port the blog post above to dev.to (it uses an iframe to get the interactive content loaded from GitHub - so you can check out the source there too)

Collapse
 
marianesantana profile image
Mariane Santana

Thank you for the comment and for sharing your post! I’d love to read it 😉

Collapse
 
reiallenramos profile image
Rei Allen Ramos

Great! I learned a lot not in 15 minutes but just 5 😊

Collapse
 
marianesantana profile image
Mariane Santana

promise accomplished haha
Thank you!

Collapse
 
taegot profile image
Terence M. Stone

Good article, I thought I didn’t understand promises well until I read your post. With each explanation and example there was, “yup”. Promise.all, Settled and .RACE are new concepts for me. Well done.

Collapse
 
marianesantana profile image
Mariane Santana

Thank you for the comment!! Sometimes we just need a simple abstraction to understand concepts in programming. I’m glad you liked ❤️

Collapse
 
pandax54 profile image
pandax54

Great, love the text. Which tool do you use to create these screen shots? They're so amazing

Collapse
 
marianesantana profile image
Mariane Santana

Thank you! I’ve used carbon.now.sh.

Collapse
 
pandax54 profile image
pandax54

thanks!! =) awesome tool!! love it

Collapse
 
spmoolman profile image
Spmoolman

Please do one for observables?

Collapse
 
marianesantana profile image
Mariane Santana

Sure !

Collapse
 
ryancolorcafe profile image
Ryan Brown

Great simple explanation, the programming world can use more articles like these! 🙌

Collapse
 
marianesantana profile image
Mariane Santana

thank you so much! ;)

Collapse
 
mikkodc profile image
mikkodc

Great tutorial. Thumbs up cause I really learned it in less than 15minutes with your article!

Collapse
 
marianesantana profile image
Mariane Santana

YAAY, thanks a lot!

Collapse
 
nezam05 profile image
Nezam uddin

Excellent! helped me to get a contrasting idea of promise and callback

Collapse
 
marianesantana profile image
Mariane Santana

Glad you liked ;)