diff --git a/spec.bs b/spec.bs index 6953d0d..256920e 100644 --- a/spec.bs +++ b/spec.bs @@ -162,6 +162,9 @@ Each {{Subscriber}} has a error callback, which is an Each {{Subscriber}} has a complete callback, which is a {{VoidFunction}}-or-null. +Each {{Subscriber}} has a teardown callbacks, which is a [=list=] of +{{VoidFunction}}s, initially empty. + Each {{Subscriber}} has a complete or error controller, which is an {{AbortController}}. @@ -176,6 +179,12 @@ Each {{Subscriber}} has a active boolean, initially tr Note: This is a bookkeeping variable to ensure that a {{Subscriber}} never calls any of the callbacks it owns after it has been [=close a subscription|closed=]. +The active getter steps are to return [=this=]'s +[=Subscriber/active=] boolean. + +The signal getter steps are to return [=this=]'s +[=Subscriber/signal=]. +
The next(|value|) method steps are: @@ -227,6 +236,21 @@ callbacks it owns after it has been [=close a subscription|closed=]. 1. [=AbortController/Signal abort=] [=this=]'s [=Subscriber/complete or error controller=].
+
+ The addTeardown(|teardown|) method steps are: + + 1. If [=this=]'s [=relevant global object=]'s [=associated Document=] is not [=Document/fully + active=], then return. + + 1. If [=this=]'s [=Subscriber/active=] is true, then [=list/append=] |teardown| to [=this=]'s + [=Subscriber/teardown callbacks=] list. + + 1. Otherwise, [=invoke=] |teardown|. + + If an exception |E| was thrown, then [=report + the exception=] |E|. +
+
To close a subscription given a {{Subscriber}} |subscriber|, run these steps: @@ -398,6 +422,25 @@ can be passed in by natively-constructed {{Observable}}s. Note: This can happen when {{SubscribeOptions}}'s {{SubscribeOptions/signal}} is already [=AbortSignal/aborted=]. + 1. Otherwise, [=AbortSignal/add=] the following algorithm to |subscriber|'s + [=Subscriber/signal=]: + + 1. [=close a subscription|Close=] |subscriber|. + + 1. [=list/For each=] |teardown| of |subscriber|'s [=Subscriber/teardown callbacks=] sorted in + reverse insertion order: + + 1. If |subscriber|'s [=relevant global object=]'s [=associated Document=] is not + [=Document/fully active=], then abort these steps. + + Note: This step runs repeatedly because each |teardown| could result in the above + {{Document}} becoming inactive. + + 1. [=Invoke=] |teardown|. + + If an exception |E| was thrown, call + |subscriber|'s {{Subscriber/error()}} method with |E|. + 1. [=Invoke=] [=this=]'s [=Observable/subscribe callback=] with |subscriber|. If an exception |E| was thrown, call