Closed
Description
It'd be nice if we could create async iterators in a similar way to iterators.
interface Whatever {
// …
async_iterable<Something>;
};
The prose would need to be a little more complicated than iterable
, probably written like a generator.
For example:
interface SlowCounter {
// …
async_iterable<unsigned long long>;
};
To asynchronously iterate over a SlowCounter
, run the following steps:
- Run these steps in parallel:
- Let i be 0.
- While true:
- Wait 1 second.
- Yield the value of i using the networking task source.
- Increment i by 1.
"Yield" would queue a task on the given task source to resolve the iteration's promise with the given value. The algorithm would not advance until the next iteration was requested.
I guess it's tricky as task sources are an HTML thing, but I can't see how it can be handled correctly otherwise.
Metadata
Metadata
Assignees
Labels
No labels