I stopped reading after the author made it clear they do not understand async/await is merely syntactic sugar for Promises.
I Avoid Async/Await
51–60 of 242 posts
Re: I Avoid Async/Await
#52It does.
Re: I Avoid Async/Await
#53By far the greatest benefit is being able to sanely implement a type-safe API. To me, it is utter madness throwing custom extensions of the Error class arbitrarily deep in the call-stack, and then having a catch handler somewhere up the top hoping that each error case is matched and correctly translated to the intended http response (at least this seems to be a common alternative).
Re: I Avoid Async/Await
#54I never liked promises when they were first introduced because I never perceived this "callback hell" to be an unmanageable problem; there are excellent libraries to manage callback composition, e.g. https://caolan.github.io/async/v3/ When Promises came along I didn't feel they added much value; in fact it made things more complicated (new paradigm, harder to compose). Still, I went with it because everyone else went…
Re: I Avoid Async/Await
#55By using async/await, we are inherently limited by the flow control because we are forced into await resolving promises.
This is why libraries like redux-saga[0] or cofx[1] use generators.
https://redux-saga.js.org https://github.com/neurosnap/cofx
Generators provide much better flexibility over flow control and allow us to treat side effects as data.
Re: I Avoid Async/Await
#56If you're doing nothing in between your async calls, using .then/.catch might be simpler. As soon as you need to introduce local variables and complex control structures, not having shared closures between your .then methods becomes extremely limiting. Hence, the async/await sugar. About having to add await to ensure your error is handled with the try catch — not putting an await before a promise is something I use a…
Re: I Avoid Async/Await
#57Now maybe it’s just my familiarity with Promises, but I look at the third example and I can quickly see an opportunity. This entire article is built around the author's ignorance and could easily be summarised as "I avoid async/await syntax because I'm more familiar with promises". The author doesn't even appear to understand that async/await is syntactic sugar for promises.
Re: I Avoid Async/Await
#58Re: I Avoid Async/Await
#59As a fullstack dev, I worked with - Spring MVC (Java Futures) - Spring Webflux (Reactor observables) - Scala (Scala Futures & for comprehensions) - TS async/await - Angular observables - React hooks (which combined with Redux, React Query etc. is a special approach to async programming.) I think it's very important to understand that ultimately, async (non-blocking) programming is kind of a "hard problem" and there i…
I don't find anything simple or clean about imperative error handling.