From 14fc4576de6738303a91e4e402afa7ad8769d4c1 Mon Sep 17 00:00:00 2001 From: Dominic Farolino Date: Fri, 17 Nov 2023 10:48:24 -0500 Subject: [PATCH 1/2] Introduce ObserverOptions for signal to live in --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 07d61e8..72693ed 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ const googTrades = streamStock('GOOG'); const nflxTrades = streamStock('NFLX'); const googController = new AbortController(); -const googSubscription = googTrades.subscribe({next: updateView, signal: googController.signal}); +const googSubscription = googTrades.subscribe({next: updateView}, {signal: googController.signal}); const nflxSubscription = nflxTrades.subscribe({next: updateView, ...}); // And the stream can disconnect later, which @@ -313,9 +313,11 @@ dictionary Observer { ObserverCallback next; VoidFunction complete; ObserverCallback error; +}; +dictionary ObserverOptions { AbortSignal signal; -}; +} dictionary PromiseOptions { AbortSignal signal; @@ -346,7 +348,7 @@ callback Visitor = undefined (any element, unsigned long long index) [Exposed=*] interface Observable { constructor(SubscribeCallback callback); - undefined subscribe(optional Observer observer = {}); + undefined subscribe(optional Observer observer = {}, optional ObserverOptions = {}); undefined finally(VoidFunction callback); @@ -474,8 +476,7 @@ let controller = new AbortController(); observable.subscribe({ next: (data) => { if (data > 100) controller.abort(); - }, - signal: controller.signal, + }}, {signal: controller.signal}, }); ``` From 8a3e3a8f4e1254dd20f520284b1c468e0d62fd2b Mon Sep 17 00:00:00 2001 From: Dominic Farolino Date: Mon, 20 Nov 2023 16:23:46 -0500 Subject: [PATCH 2/2] Rename --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 72693ed..8586d46 100644 --- a/README.md +++ b/README.md @@ -315,7 +315,7 @@ dictionary Observer { ObserverCallback error; }; -dictionary ObserverOptions { +dictionary SubscribeOptions { AbortSignal signal; } @@ -348,7 +348,7 @@ callback Visitor = undefined (any element, unsigned long long index) [Exposed=*] interface Observable { constructor(SubscribeCallback callback); - undefined subscribe(optional Observer observer = {}, optional ObserverOptions = {}); + undefined subscribe(optional Observer observer = {}, optional SubscribeOptions = {}); undefined finally(VoidFunction callback);