Even with async/await, raw promises are still key to writing optimal concurrent javascript
Daniel Brain
1.6K35

It feels like there’s still a more straightforward version of the async/await makePizza method missing, that’s quite clear about what’s happening:

async function makePizza(sauceType = 'red') {
const makingDough = makeDough()

const sauce = await makeSauce(sauceType)
const cheese = await grateCheese(sauce.determineCheese())

const dough = await makingDough
dough.add(sauce)
dough.add(cheese)
   return dough
}

As an aside, it would be nice if there was different syntax highlighting in IDEs for variables that contain promises, to make it more obvious where processes are running asynchronously.

Like what you read? Give Alf Eaton a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.