DEV Community

Cover image for ES6 Promise | Promise.all | Promise.race | Promise.allSettled
Midas/XIV
Midas/XIV

Posted on • Edited on

ES6 Promise | Promise.all | Promise.race | Promise.allSettled

Promise State Definitions

State Definition
Fulfilled When a promise is resolved successfully
Rejected When a promise failed.
Pending When a promise is “neither fulfilled nor rejected“.
Settled Not really a state but an umbrella term to describe that a promise is either fulfilled or rejected.

Hey guys ! Once again I'm back with an indepth video were we discuss ES6 Promises. I know that async/await is the new way people prefer to deal with async code but I think it's always good to know about callback functions, promises, and promise methods.

Also In this video we take a look at Promise.allSettled( ) method which is part of ECMAScript 2020 and can be used in the latest release of Node.js.

In this video we'll have a look at how to convert a request which uses callback functions to request that returns a promise. We'll have a look at how to avoid callback hell by promise chaining.
We'll then have a look at promise methods like: Promise.al(),Promise.race(),Promise.any(),Promise.allSettled(),


For those of you who don't use node.js this is a basic template to follow along.
Code Pen : https://codepen.io/midasxiv/pen/RwwoxvX
Make sure you view the 'console' somewhere in the bottom left.

Video Index:

  • 01:44 - Request Package. ( node.js )
  • 03:30 - Request Callback function.
  • 06:10 - Promise Constructor / Convert callback to promise. (pure JavaScript )
  • 11:20 - Promise Chaining & Promise.then()
  • 12:43 - Promise.catch() & Promise.reject()
  • 14:23 - Promise.all()
  • 17:30 - Promise.race()
  • 19:30 - Promise.any()
  • 19:30 - Promise.allSettled()
  • 22:00 - Outro

If you liked the content checkout my youtube channel.
YouTube video :




image

Top comments (2)

Collapse
 
astr0sl0th profile image
Joe Hill

It's got to be said Promise.all() is massively underutilized in my opinion it can really make your code a lot cleaner. Great article.

Collapse
 
sandeepmeta profile image
sandeepmeta

There is no any link to access the YouTube video, can anyone ??