JavaScript Promises from the Ground Up(joshwcomeau.com)
joshwcomeau.com
JavaScript Promises from the Ground Up
https://www.joshwcomeau.com/javascript/promises/
5 comments
Agreed. This is very well written.
I discovered the joy of Go from dealing with JavaScript promises while writing an API service in Node. So many painful runtime errors uncaught or unlogged because promises don’t (or didn’t) require the catch callback.
I think inverting the programming perspective to default to sync instead of async is more productive for web services development, than perhaps for UI.
I discovered the joy of Go from dealing with JavaScript promises while writing an API service in Node. So many painful runtime errors uncaught or unlogged because promises don’t (or didn’t) require the catch callback.
I think inverting the programming perspective to default to sync instead of async is more productive for web services development, than perhaps for UI.
See my comment above and also
https://news.ycombinator.com/item?id=40825220
And
https://news.ycombinator.com/item?id=40240905
https://news.ycombinator.com/item?id=40825220
And
https://news.ycombinator.com/item?id=40240905
>
the await keyword is syntactic sugar for the .then() callback:
async/await is not just syntactic sugar. See
https://news.ycombinator.com/item?id=23701736
And the rest of thread
async/await is not just syntactic sugar. See
https://news.ycombinator.com/item?id=23701736
And the rest of thread
It depends on what you mean by syntactic sugar. I follow this definition: https://en.wikipedia.org/wiki/Syntactic_sugar
You can indeed translate an async function to an equivalent function that uses .then() but it’s a radical change, not syntactic sugar (as I use that term).
You can indeed translate an async function to an equivalent function that uses .then() but it’s a radical change, not syntactic sugar (as I use that term).
I would love a follow-up that fills the gap about the relatio ship between generator functions and promises though.
This part seems very transparent in practise, but I think they're also the reason why the article gets slightly fuzzy at the end.
It claims that 99% of developers need not to care about promise "unwrapping".
But isn't that what powers every async function with more than one "await" in it?
Would also love to read a thorough breakdown of immediately resolved promises and their duality with setTimeout(resolve, 0).