From 3384ee3af24815571465f864b91d8e753cead155 Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Fri, 28 Jun 2024 23:49:14 +0900 Subject: [PATCH] Check subscriber's `active` state in `next()`, `error()`, and `complete()` (#129) --- spec.bs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/spec.bs b/spec.bs index 3d8a171..cd068b0 100644 --- a/spec.bs +++ b/spec.bs @@ -164,13 +164,13 @@ interface Subscriber { Each {{Subscriber}} has a next algorithm, which is a [=internal -observer/next steps=]-or-null. +observer/next steps=]. Each {{Subscriber}} has a error algorithm, which is an [=internal -observer/error steps=]-or-null. +observer/error steps=]. Each {{Subscriber}} has a complete algorithm, which is a [=internal -observer/complete steps=]-or-null. +observer/complete steps=]. Each {{Subscriber}} has a teardown callbacks, which is a [=list=] of {{VoidFunction}}s, initially empty. @@ -198,11 +198,12 @@ The signal getter steps are to
The next(|value|) method steps are: + 1. If [=this=]'s [=Subscriber/active=] is false, then return. + 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 algorithm=] is not null, then run [=this=]'s - [=Subscriber/next algorithm=] given |value|. + 1. Run [=this=]'s [=Subscriber/next algorithm=] given |value|. [=Assert=]: No exception was thrown. @@ -220,37 +221,35 @@ The signal getter steps are to
The error(|error|) method steps are: + 1. If [=this=]'s [=Subscriber/active=] is false, [=report the exception=] |error|, then return. + 1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated Document=] is not [=Document/fully active=], then return. - 1. Let |error algorithm| be [=this=]'s [=Subscriber/error algorithm=]. - 1. [=close a subscription|Close=] [=this=]. 1. [=AbortController/Signal abort=] [=this=]'s [=Subscriber/complete or error controller=]. - 1. If |error algorithm| is not null, then run |error algorithm| given |error|. + 1. Run [=this=]'s [=Subscriber/error algorithm=] given |error|. [=Assert=]: No exception was thrown. Note: See the documentation in {{Subscriber/next()}} for details on why this is true. - - 1. Otherwise (i.e., when |error algorithm| is null), [=report the exception=] |error|.
The complete() method steps are: + 1. If [=this=]'s [=Subscriber/active=] is false, then return. + 1. If [=this=]'s [=relevant global object=] is a {{Window}} object, and its [=associated Document=] is not [=Document/fully active=], then return. - 1. Let |complete algorithm| be [=this=]'s [=Subscriber/complete algorithm=]. - 1. [=close a subscription|Close=] [=this=]. 1. [=AbortController/Signal abort=] [=this=]'s [=Subscriber/complete or error controller=]. - 1. If |complete algorithm| is not null, then run |complete algorithm|. + 1. Run [=this=]'s [=Subscriber/complete algorithm=]. [=Assert=]: No exception was thrown. @@ -277,9 +276,6 @@ The signal getter steps are to 1. Set |subscriber|'s [=Subscriber/active=] boolean to false. - 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 internal state of a {{Subscriber}}. It's important that this algorithm sets