Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spec the toArray() operator #97

Merged
merged 3 commits into from
Jan 16, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ urlPrefix: https://dom.spec.whatwg.org; spec: DOM
text: passive; url: event-listener-passive
text: once; url: event-listener-once
text: signal; url: event-listener-signal
for: AbortSignal
text: dependent signals; url: abortsignal-dependent-signals
</pre>

<style>
Expand Down Expand Up @@ -521,7 +523,7 @@ An <dfn>internal observer</dfn> is a [=struct=] with the following [=struct/item
Note: This can happen when {{SubscribeOptions}}'s {{SubscribeOptions/signal}} is already
[=AbortSignal/aborted=].

1. Otherwise, [=AbortSignal/add=] the following algorithm to |subscriber|'s
1. Otherwise, [=AbortSignal/add|add the following abort algorithm=] to |subscriber|'s
[=Subscriber/signal=]:

1. [=close a subscription|Close=] |subscriber|.
Expand Down Expand Up @@ -603,23 +605,44 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w
<div algorithm>
The <dfn for=Observable method><code>toArray(|options|)</code></dfn> method steps are:

1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated
Document=] is not [=Document/fully active=], then return.
domfarolino marked this conversation as resolved.
Show resolved Hide resolved

1. Let |p| [=a new promise=].

1. If |options|'s {{SubscribeOptions/signal}} is not null:

1. If |options|'s {{SubscribeOptions/signal}} is [=AbortSignal/aborted=], then:

1. [=Reject=] |p| with |options|'s {{SubscribeOptions/signal}}'s [=AbortSignal/abort
reason=].

1. Return |p|.

1. [=AbortSignal/add|Add the following abort algorithm=] to |options|'s
{{SubscribeOptions/signal}}:

1. [=Reject=] |p| with |options|'s {{SubscribeOptions/signal}}'s [=AbortSignal/abort
reason=].

Note: All we have to do here is [=reject=] |p|. Note that the subscription to [=this=]
{{Observable}} will also be canceled automatically, since the "inner"
[=Subscriber/signal=] (created during <a for=Observable lt="subscribe to an
Observable">subscription</a>) is a [=AbortSignal/dependent signal=] of |options|'s
{{SubscribeOptions/signal}}.

1. Let |values| be a new [=list=].

1. Let |observer| be a new [=internal observer=], initialized as follows:

: [=internal observer/next steps=]
:: <span class=XXX>TODO: Add the value to |values|.</span>
:: [=list/Append=] the passed in <var ignore>value</var> to |values|.

: [=internal observer/error steps=]
:: <span class=XXX>TODO: [=Reject=] |p| with an error.</span>
:: [=Reject=] |p| with the passed in <var ignore>error</var>.

: [=internal observer/complete steps=]
:: <span class=XXX>TODO: [=Resolve=] |p| with |values|.</span>

1. <span class=XXX>TODO: Finish the actual spec for this method and use |options|'s
{{SubscribeOptions/signal}} to [=reject=] |p| appropriately.</span>
:: [=Resolve=] |p| with |values|.

1. <a for=Observable lt="subscribe to an Observable">Subscribe</a> to [=this=] given |observer|
and |options|.
Expand Down