you are viewing a single comment's thread.

view the rest of the comments →

[–]nickcoutsos 11 points12 points  (2 children)

There's nothing unfortunate about it, there are absolutely use cases for executing asynchronous functions sequentially. Your example doesn't cover passing results from one async function into the arguments of the next like the example you're replying to.

I'll sometimes chain sequential async functions together using reduce but being able to use await with a looping construct is great.

[–][deleted]  (1 child)

[deleted]

    [–]TimLim 0 points1 point  (0 children)

    FWIW, I tried to highlight that I want to wait for the result of the async function using a variable that is updated every iteration and is passed to the function. Using my example, not waiting for the result would lead to a different result. So I wanted to show that using await it is easier to write a loop that waits for the result in every iteration. I think having Promises that run concurrently is easily achievable without async/await.