News for hackers. Stuff that matters.
Re:I Avoid Async/Await by madeofpalk on Saturday April 16, 2022 @07:57AM (#31051615)
One thing I really like async/await for is you can use them in for-loops. It makes it significantly easier to do async work in what was previously very synchronous.
Re:I Avoid Async/Await by ElFitz on Saturday April 16, 2022 @12:46PM (#31053831)
I thought await in loops was a big no no, unless it has changed since I last checked?

Doesn’t it remove any opportunity for parallelism, making the loop take much longer than it would with a Promise.all?

Or am I missing something?

Re:I Avoid Async/Await by madeofpalk on Saturday April 16, 2022 @01:48PM (#31054368)
You're right(ish) - the async functions would not run in parallel. But sometimes that's either fine, or I don't want them to run in parallel.
Re:I Avoid Async/Await by ElFitz on Thursday April 21, 2022 @08:26PM (#31116829)
It’s funny; I never thought of it as a desirable behaviour.

To each their own!

Re:I Avoid Async/Await by yourad_io on Saturday April 16, 2022 @01:08PM (#31054025)
Sometimes you want to do things sequentially, so for..of x { await } is the way to go

If you want parallelism: await Promise.all(x.map(...))