Promises and the allSettled Method

  Рет қаралды 6,058

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

Күн бұрын

In 2019, a new method was added to the Promise object - allSettled.
The method lets us run some code when the results of a collection of Promises have all been determined, regardless of whether or not they were resolved or rejected.
Code from video: gist.github.co...
CanIUse reference: caniuse.com/md...

Пікірлер: 19
@RohitKumar-xs3wh
@RohitKumar-xs3wh 4 жыл бұрын
cant miss your video notification, your way of explanation is gold!
@hedovillaspuertobanusnamas5566
@hedovillaspuertobanusnamas5566 4 жыл бұрын
Thanks Steve, I found your videos the very best online. Impossible not to understand. Well done, much appreciated
@zyriab5797
@zyriab5797 2 жыл бұрын
Clear, to the point and with nice examples. Thanks!
@Gollumfili
@Gollumfili 3 жыл бұрын
Another brilliant video. Please keep them coming!
@lordfresh
@lordfresh 3 жыл бұрын
Amazing explanation, Steve. Thank you. It helped me a lot :)
@amitmondal7427
@amitmondal7427 4 жыл бұрын
You are the JavaScript Hero
@mattsmith6828
@mattsmith6828 Жыл бұрын
Super helpful! Thank you! The only thing left for me to learn about promises is how to handle a Promise nested in the "success"/".then" function of an outer Promise. I don't know if that's even possible. Sure would be nice lol
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 Жыл бұрын
A then( ) method call returns a Promise (or rather, wraps the return value of the function inside itself with a Promise). If the function returns a Promise then the two promises are flattened into a single Promise. If there is a next then( ) method, then it will be called when the flattened promise is resolved. Here is a chain of then methods showing different types of things being returned from each then( ) method function. new Promise((resolve, reject) => { resolve(42); }) .then(num => { console.log(num); //42 return new Promise(resolve =>{ resolve(num); }); }) .then( num => { console.log(num); // still 42 return Promise.resolve(num); }) .then( num => { console.log(num); //still 42 return num; }) .then(num => { console.log(num); //still 42 let arr = [Promise.resolve(num), new Promise(resolve=>resolve(123), fetch('someurl') ]; return Promise.all(arr) }) .then(results=>{ //results is an array of the values from the resolved promises });
@mattsmith6828
@mattsmith6828 Жыл бұрын
@@SteveGriffith-Prof3ssorSt3v3 thank you! i'll give this a look.
@barungh
@barungh 4 жыл бұрын
No doubt, JS is best at you !👍👌💐💐💐
@BrettCooper4702
@BrettCooper4702 4 жыл бұрын
Does Promise.allSettled() even need a .catch() ?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 4 жыл бұрын
Yes. Things can still go wrong. In Node you will get warnings for any Promise without a catch.
@BlackBoy-gq4jt
@BlackBoy-gq4jt 4 жыл бұрын
clear and concise.
@SBSS_Future_Truks
@SBSS_Future_Truks 4 жыл бұрын
Skeee grififf 🤟🏽 learned a lot graditude
@nik08101986
@nik08101986 2 жыл бұрын
If any api is giving too much delay .. while fetching response, then all settled function should be blocked... Till waiting for it
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 2 жыл бұрын
Yes. This applies to all HTTP requests from the browser, not just API calls. The browser will eventually time out if the request is taking too long.
@نقطة-ي4ج
@نقطة-ي4ج 4 жыл бұрын
please, i love to see you, to remake your populare videos with better quality videos and sounds. and better zoom level for mobile viewers.
@MRABDULALI-123
@MRABDULALI-123 2 жыл бұрын
Really great but sometimes you think your audience is only pros not the begineers
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 2 жыл бұрын
Some videos are for beginners and others are on topics that won't mean much to beginners. For many topics I have to assume a certain amount of background knowledge. I present the content the same way I would in the classroom. Online the topics are available for anyone at any level who wants to explore the topic, regardless of their experience level.
The new Promise any method
5:34
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 3 М.
The Async Await Episode I Promised
12:04
Fireship
Рет қаралды 1,1 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
The Rust Survival Guide
12:34
Let's Get Rusty
Рет қаралды 177 М.
Converting Callback Functions to Promises
12:35
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 7 М.
Programming Is NOT Enough | Add these 7 skills…
13:19
Travis Media
Рет қаралды 425 М.
JavaScript Promises In 10 Minutes
11:31
Web Dev Simplified
Рет қаралды 1,8 МЛН
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 997 М.
Ten Steps to Mastering the Fetch API
2:19:52
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 51 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 680 М.
My 10 “Clean” Code Principles (Start These Now)
15:12
Conner Ardman
Рет қаралды 320 М.