from()
: Support async iterable conversion
#193
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR closes #191 by spec'ing async iterable support. Along with support for general iteration over async iterables, we support consulting the Subscriber's signal to discontinue the iteration at three points:
Additionally, an abort algorithm to call ECMAScript's AsyncIteratorClose() abstract operation is added to the subscriber's signal before iteration begins. This ensures that the iterator's
return()
method is called with the abort signal's abort reason if it gets aborted before the iteration organically completes. This is also tested (see https://wpt.fyi/results/dom/observable/tentative/observable-from.any.html) in a number of situations.As alluded to, we mostly delegate to various ECMAScript abstract operations that govern iteration, but once whatwg/webidl#1397 lands should be able to use the abstractions offered in Web IDL directly, instead of manage most of it manually here. For now, this PR is somewhat redundant with the Web IDL one. It uses similar constructs to iterate over the async iterator.
Preview | Diff