Skip to content

Commit

Permalink
Iterator Record
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino committed Sep 2, 2024
1 parent 4c74aa8 commit d328e70
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -512,27 +512,28 @@ An <dfn>internal observer</dfn> is a [=struct=] with the following [=struct/item
1. If [$IsCallable$](|asyncIteratorMethodRecord|'s \[[Value]]) is false, then
[=exception/throw=] a {{TypeError}}.

Otherwise, let |nextAlgorithm| be the following steps, given |subscriber| and |iterator|:
1. Let |nextAlgorithm| be the following steps, given a {{Subscriber}} |subscriber| and an
Iterator Record |iteratorRecord|:

1. If |iterator|'s \[[Done]] is true, then: run |subscriber|'s {{Subscriber/complete()}}
method and abort these steps.
1. If |iteratorRecord|'s \[[Done]] is true, then: run |subscriber|'s
{{Subscriber/complete()}} method and abort these steps.

1. Let |nextRecord| be [$IteratorStepValue$](|iterator|).
1. Let |nextRecord| be [$IteratorStepValue$](|iteratorRecord|).

1. Let |nextPromise| be undefined.

1. If |nextRecord| is a [=throw completion=], then set |nextPromise| to [=a promise
rejected with=] |nextRecord|'s \[[Value]].
1. If |nextRecord| is a [=throw completion=], then set |nextPromise| to [=a promise
rejected with=] |nextRecord|'s \[[Value]].

1. Otherwise, set |nextPromise| to |nextRecord|'s \[[Value]].
Otherwise, set |nextPromise| to |nextRecord|'s \[[Value]].

1. [=React=] to |nextPromise|:

1. If |nextPromise| was fulfilled with value |v|, then:

1. Run |subscriber|'s {{Subscriber/next()}} method, given |v|.

1. Run |nextAlgorithm|, given |subscriber| and |iterator|.
1. Run |nextAlgorithm|, given |subscriber| and |iteratorRecord|.

1. If |nextPromise| was rejected with reason |r|, then run |subscriber|'s
{{Subscriber/error()}} method, given |r|.
Expand All @@ -545,8 +546,8 @@ An <dfn>internal observer</dfn> is a [=struct=] with the following [=struct/item
1. If |iteratorRecord| is a [=throw completion=], then [=queue a microtask=] to run
|subscriber|'s {{Subscriber/error()}} method, given |iteratorRecord|'s \[[Value]].

1. Otherwise, [=queue a microtask=] to run |nextAlgorithm| given |subscriber| and
|iteratorRecord|'s \[[Value]].
Otherwise, [=queue a microtask=] to run |nextAlgorithm| given |subscriber| and
|iteratorRecord|.

Note: It is important to [=queue a microtask=] in both branches here to guarantee that
coercing an AsyncIterable never stops the Subscription synchronously, thereby releasing
Expand Down

0 comments on commit d328e70

Please sign in to comment.