JavaScript Promises from the Ground Up
joshwcomeau.com
joshwcomeau.com
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).
https://news.ycombinator.com/item?id=40825220
And
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.
async/await is not just syntactic sugar. See
https://news.ycombinator.com/item?id=23701736
And the rest of thread
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).