Await is the new black
Aurélien Hervé

Nice article, I’ve been working without it now but have been able to gain some similar benefit without babel or typescript by using co with generators. Effectively replacing async with co.wrap and await with yield. It certainly makes writing async-heavy test a lot nicer.

Destructuring can grant a lot of benefit as well when trying to un-nest promises. For those without async-await, or co access.

For Example:

const demoPromise = (userId) => {
return User
.then(user => Promise.all([user, doSomethingAsync(user)]))
.then(([user, result]) => finalResult(user, result));

Async/await is going to be great when it’s officially released, but even now there are ways to start working towards better promises or async code.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.