Skip to content

What about Async, Await and Generators?

Daniel Levy edited this page Jul 8, 2017 · 8 revisions

Lions, tigers and bears!

I have seen what feels like 1,000 articles on how Async/Await killed Promises, "victory!" Right?

Not so fast.

While there are a few excellent articles appropriately skeptical of async/await, such as ES7 async functions - a step in the wrong direction

Most of the press out there seems closer to articles like From Promise API to Async-Await and 6 Reasons Why JavaScript’s Async/Await Blows Promises Away

The issue with these articles? They use weak Promise examples, and are usually too oversimplified to make any real conclusion.

Here's how I might refactor one of those code samples:

image

Essentially, async/await is a step backwards for JS & it's current patterns.

Simple examples are merely distracting, the Async/Await feature itself is too flexible, allowing poorly thought-out spaghetti code.

Perhaps more sinister, the initial version may seem great - even if only running single-threaded. Inevitably as time passes, features are added and before long you have a mess. ("Let's add a permissions check, stick it before profile.update(); add a special logging call there too..." - please just stop smashing crap together & committing.)

Clone this wiki locally