Skip to content

Commit

Permalink
Introduce ObserverOptions for signal to live in (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino authored Nov 20, 2023
1 parent 6e0ad3f commit 1dc5463
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -313,9 +313,11 @@ dictionary Observer {
ObserverCallback next;
VoidFunction complete;
ObserverCallback error;
};

dictionary SubscribeOptions {
AbortSignal signal;
};
}

dictionary PromiseOptions {
AbortSignal signal;
Expand Down Expand Up @@ -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 SubscribeOptions = {});

undefined finally(VoidFunction callback);

Expand Down Expand Up @@ -474,8 +476,7 @@ let controller = new AbortController();
observable.subscribe({
next: (data) => {
if (data > 100) controller.abort();
},
signal: controller.signal,
}}, {signal: controller.signal},
});
```

Expand Down

0 comments on commit 1dc5463

Please sign in to comment.