diff --git a/spec.bs b/spec.bs
index 40121ff..1255d08 100644
--- a/spec.bs
+++ b/spec.bs
@@ -161,14 +161,14 @@ interface Subscriber {
};
-Each {{Subscriber}} has a next callback, which is an
-{{ObserverCallback}}-or-null.
+Each {{Subscriber}} has a next algorithm, which is a [=internal
+observer/next steps=]-or-null.
-Each {{Subscriber}} has a error callback, which is an
-{{ObserverCallback}}-or-null.
+Each {{Subscriber}} has a error algorithm, which is an [=internal
+observer/error steps=]-or-null.
-Each {{Subscriber}} has a complete callback, which is a
-{{VoidFunction}}-or-null.
+Each {{Subscriber}} has a complete algorithm, which is a [=internal
+observer/complete steps=]-or-null.
Each {{Subscriber}} has a teardown callbacks, which is a [=list=] of
{{VoidFunction}}s, initially empty.
@@ -199,11 +199,9 @@ The signal
getter steps are to
1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated
Document=] is not [=Document/fully active=], then return.
- 1. If [=this=]'s [=Subscriber/next callback=] is non-null, [=invoke=] this's [=Subscriber/next
- callback=] with |value|.
+ 1. Run [=this=]'s [=Subscriber/next algorithm=] algorithm given |value|.
- If an exception |E| was thrown, then [=report
- the exception=] |E|.
+ [=Assert=]: No exception was thrown.
signal
getter steps are to
1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated
Document=] is not [=Document/fully active=], then return.
- 1. Let |callback| be [=this=]'s [=Subscriber/error callback=].
+ 1. Let |error algorithm| be [=this=]'s [=Subscriber/error algorithm=].
1. [=close a subscription|Close=] [=this=].
- 1. If |callback| is not null, [=invoke=] |callback| with |error|.
-
- If an exception |E| was thrown, then [=report
- the exception=] |E|.
+ 1. Run |error algorithm| given |error|.
- 1. Otherwise, [=report the exception=] |error|.
+ [=Assert=]: No exception was thrown.
1. [=AbortController/Signal abort=] [=this=]'s [=Subscriber/complete or error controller=].
signal
getter steps are to
1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated
Document=] is not [=Document/fully active=], then return.
- 1. Let |callback| be [=this=]'s [=Subscriber/complete callback=].
+ 1. Let |complete algorithm| be [=this=]'s [=Subscriber/complete algorithm=].
1. [=close a subscription|Close=] [=this=].
- 1. If |callback| is not null, [=invoke=] |callback|.
+ 1. Run |complete algorithm|.
- If an exception |E| was thrown, then [=report
- the exception=] |E|.
+ [=Assert=]: No exception was thrown.
1. [=AbortController/Signal abort=] [=this=]'s [=Subscriber/complete or error controller=].
@@ -264,8 +258,8 @@ The signal
getter steps are to
1. Set |subscriber|'s [=Subscriber/active=] boolean to false.
- 1. Set |subscriber|'s [=Subscriber/next callback=], [=Subscriber/error callback=], and
- [=Subscriber/complete callback=] all to null.
+ 1. Set |subscriber|'s [=Subscriber/next algorithm=], [=Subscriber/error algorithm=], and
+ [=Subscriber/complete algorithm=] all to null.
This algorithm intentionally does not have script-running side-effects; it just updates the
@@ -392,33 +386,129 @@ callback). The return value of {{EventTarget/on()}} is an example of the latter.
The subscribe(|observer|, |options|)
method steps
are:
+ 1. Subscribe to [=this=] given |observer|
+ and |options|.
+
The [=internal observer=] [=struct=] is used to mirror the {{Observer/next}}, + {{Observer/error}}, and {{Observer/complete}} [=callback functions=]. For any {{Observable}} that + is subscribed by JavaScript via the {{Observable/subscribe()}} method, these algorithm "steps" + will just be a wrapper around [=invoking=] the corresponding {{Observer/next}}, + {{Observer/error}}, and {{Observer/complete}} [=callback functions=] provided by script.
+ +But when internal spec prose (not user script) subscribes to an {{Observable}}, these "steps" are arbitrary spec algorithms that + are not provided via an {{ObserverUnion}} packed with Web IDL [=callback functions=]. See the + [[#promise-returning-operators]] that make use of this, for example.
+toArray(|options|)
method steps are:
- 1. TODO: Spec this and use |options|.
+ 1. Let |p| [=a new promise=].
+
+ 1. Let |values| be a new [=list=].
+
+ 1. Let |observer| be a new [=internal observer=], initialized as follows:
+
+ : [=internal observer/next steps=]
+ :: TODO: Add the value to |values|.
+
+ : [=internal observer/error steps=]
+ :: TODO: [=Reject=] |p| with an error.
+
+ : [=internal observer/complete steps=]
+ :: TODO: [=Resolve=] |p| with |values|.
+
+ 1. TODO: Finish the actual spec for this method and use |options|'s
+ {{PromiseOptions/signal}} to [=reject=] |p| appropriately.
+
+ 1. Subscribe to [=this=] given |observer|
+ and |options|.
+
+ 1. Return |p|.