From 9f8040dd5a130121137fc6a78b6eee51dcdd00ab Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Thu, 27 Jun 2024 18:53:25 +0900 Subject: [PATCH] Make `Subscriber` interface's _next/error/complete algorithm_ non-nullable Now, we use `Subscriber.active` to know the `Subscriber` never calls any of the callbacks it owns after it has been closed. So we don't have to use the way to check whether their algorithms are null or not to know `Subscriber` is still active or not. --- spec.bs | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/spec.bs b/spec.bs index 790949d..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. @@ -203,8 +203,7 @@ 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 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. @@ -227,19 +226,15 @@ 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. 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|.
@@ -250,13 +245,11 @@ 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. 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. @@ -283,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