>
> There's a tradeoff here.
>
> If it's an extension of `for...of`, it's much clearer for users. If it's
> a method of `Promise`, it's much more extensible.
>
> Perhaps it could be a little bit of both?
>
> Maybe something like:
> ```
> for(item of items : Scheduler.limit(5)) {
> // ...
> }
> ```
>
> where `Scheduler.limit` is one of several possible execution strategies?
>
> Cheers,
> David
>
>
I like this idea a lot; it builds on the goal of staying in the linear
async/await mindset (as you say, clearer for users) while providing
extensibility.
The idea of passing in a function that implements the concurrency strategy
is great. 'm a little unclear on how the syntax transformation you
suggested would do the trick, I think the loop body would have to get
wrapped in an anonymous async function. I'm not sure whether a generator is
required.
I would imagine the strategy function would receive an iterable (or async
iterable, depending on whether "for await" was used) that retrieves
promises, one for each loop body, and can thus pull them at its own pace.
--
Chief Software Architect
Apostrophe Technologies
Pronouns: he / him / his
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss