- From: Mattias Buelens <notifications@github.com>
- Date: Tue, 26 Mar 2024 02:48:11 -0700
- To: whatwg/webidl <webidl@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/webidl/pull/1397/review/1959823649@github.com>
@MattiasBuelens requested changes on this pull request. Looking pretty good! > +Note: Instead of returning an async iterable from an IDL operation, the operation should return an +[=interface=] that has an [=asynchronously iterable declaration=]. + +<h5 id="js-async-iterable-iteration">Iterating async iterables</h5> + +<div algorithm> + + To <dfn id="async-iterable-get-next-value" export lt="get an async iterable next value">get the next value</dfn> of an + <code><a lt="async iterable type">async iterable<<var>T</var>></a></code> |iteratorRecord|, + perform the following steps: + + 1. Let |nextResult| be the result of calling <a abstract-op>IteratorNext</a>(|iteratorRecord|). + 1. If |nextResult| is an abrupt completion, return [=a promise rejected with=] + |nextResult|.\[[Value]]. + 1. Let |nextPromise| be [=a promise resolved with=] |nextResult|.\[[Value]]. + 1. Return the result of [=reacting=] to |nextPromise| with with the following fulfillment ```suggestion 1. Return the result of [=reacting=] to |nextPromise| with the following fulfillment ``` > + +</div> + +<div algorithm> + + To <dfn id="async-iterable-finish-iterating" export lt="finish iterating an async iterable">finish iterating</dfn> an + <code><a lt="async iterable type">async iterable<<var ignore>T</var>></a></code> |iteratorRecord|, + perform the following steps: + + 1. Let |iterator| be |iteratorRecord|.\[[Iterator]]. + 1. Let |returnMethod| be <a abstract-op>GetMethod</a>(|iterator|, "return"). + 1. If |returnMethod| is an abrupt completion, return [=a promise rejected with=] + |returnMethod|.\[[Value]]. + 1. If |returnMethod| is <emu-val>undefined</emu-val>, return [=a promise resolved with=] + <emu-val>undefined</emu-val>. + 1. Let |returnResult| be <a abstract-op>Call</a>(|returnMethod|.\[[Value]], |iterator|). For [`ReadableStream.from(asyncIterable)`](https://streams.spec.whatwg.org/#readable-stream-from-iterable), we need a way to pass an optional `reason` to the `return()` call. I propose we add an optional `value` argument to "finish iterating an async iterable". -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/webidl/pull/1397#pullrequestreview-1959823649 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/webidl/pull/1397/review/1959823649@github.com>
Received on Tuesday, 26 March 2024 09:48:15 UTC