- From: Domenic Denicola <notifications@github.com>
- Date: Tue, 14 Feb 2023 23:14:04 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 15 February 2023 07:14:16 UTC
I am pretty sure we designed Web IDL's async iterator machinery this way, to make it follow JavaScript async generators. That is, if you do ```jsasync function* g() { await sleep(100); yield 1; await sleep(100); yield 2; await sleep(100); yield 3; } const gen = g(); console.log(await gen.next()); // { value: 1, done: false } const p = gen.next(); // intentionally no `await` gen.return(); console.log(await p); // { value: 2, done: false }, i.e. the ongoing processing to produce 2 is let to continue. console.log(await gen.next()); // { value: undefined, done: true } ``` The async iterator protocol itself would allow us to do something different here, but I'm unsure if we should depart from async generator behavior... -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/issues/1255#issuecomment-1430862570 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/issues/1255/1430862570@github.com>
Received on Wednesday, 15 February 2023 07:14:16 UTC