Just FYI, I previously suggested a couple things substantially more
flexible than this [1] [2] (originated from this [3]), and it mostly
fell flat due to being highly premature. Anything exclusive to
promises is unlikely to win as library methods exist for basically all
use cases and from my experi
...strike that, I misread the "but that still waits for the async
functions to complete" part. So what you're proposing is that
everything functions normally inside the curly braces, but execution
doesn't continue until all promises have resolved? So your example
would work essentially like this:
>Maybe if you drop the "await" in your example:
>
>```javascript
>await.all {
>const x = doSomethingAsync();
>//x is just the promise here
>}
>```
>
>...but that still waits for the async functions to complete, I think it would
>cause fewer bugs and would seem to still satisfy the motivatio
Hello!
> This [current] structure is also just fundamentally different from working
> serially in async/await and it forces you to reason about the problem
> in a specific way. This doesn't appear to be a conscious decision to
> force good code practices
Actually I'd argue that it is. Doing stuff
I don't like the idea of await behaving differently inside vs outside of
the "await.all" block, and I think is a source of bugs:
await.all {
const x = await doSomethingAsync();
//x is still undefined here! Not the case outside of an await.all block
}
Maybe if you drop the "await" in your
(Just realised I forgot to reply all! Whoops!)
Can't we just use destructuring defaults for this, given it seems that
both V8 and SpiderMonkey lazily invoke functions in this context? I
haven't corroborated this with the spec though, so I could be wrong.
const log = name => fn => (...args) =>
There's `for await` loops since recently, there could be `await for` loops
for wrapping the whole execution of a loop
```js
console.time(1);
await for (const fn of [()=>delay(50).then(()=>'a'),
()=>delay(80).then(()=>'b')]) {
console.timeLog(1, await fn());
}
console.timeEnd(1);
```
This would
7 matches
Mail list logo