Photo by Ryan Franco on Unsplash
What’s new in JavaScript (Google I/O ’19) on May 8, 2019 showed what’s coming/available for s...
For further actions, you may consider blocking this person and/or reporting abuse
For further actions, you may consider blocking this person and/or reporting abuse
Great post and explanation! I personally have dreaded not having an alternative to
Promise.allSettled()
as it has required me to rewrite much of my applications to still work withPromise.all()
. It usually happens anytime there's a need to gather finalized data AFTER running async methods from an array.Thank you, vulpz 😃
How did you get around the issue of current short-circuit behavior of
.all()
? (write a custom.allSettled
or used many try/catch blocks? Those are only two I can think of 🤔)Possibly bad form, but I went the route of "misusing"
resolve
andreject
. If there was a bad case that had issues, yet needed to be caught byPromise.all()
, I returned an object that used the try/catch but searched for a specific flag.Not the most efficient, but it worked and was easier to implement than rewriting the majority of the project!
Getting things done FTW~
Great article! I wasn't even aware of the new Promise features but you did a good job of explaining them.
Also, it looks like you need to swap line 2 and 3 in your Promise.any example output gist so they correspond to the example order. :)
I think that they correspond to the example order....
It is because of setTimeout(....
I agree that they correspond to what output you would get from the code (because of
setTimeout()
), but I don't agree that they correspond to the example order.Maybe what I should have said was that to make the example and output more readable, one would swap example 2 and 3. That way the output Gist corresponds to the example order and the actual output of the code.
Thanks Jesper for the suggestion.
I've updated the "output" with comments.
The reason I left the order as it was because I initially expected people to "copy/paste" the code and see the result.
(as opposed to copy/paste each example one at a time)
Behold the power of Gist, now all my x-posts are updated too 😀
I will take notes of your suggestion when I post any types of examples next time.
Good post, looking forward to seeing these implemented in all browser vendors
Thanks.
These methods will rid the need for boilterplate codes for sure :)
This was an awesome article, 👍🏼 really helped understand the different static methods of a promise.
Thanks for the kind words, David. Glad that you liked it :)
So, what is the purpose of extractApples method? It seem to be be defined, but never used?
Thank you @wormss for catching the vestigial code and I apologize for getting back late.
I removed
extractApples
from the code snippet as it's "never used" :)