Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ObserverOptions for signal to live in #85

Merged
merged 2 commits into from
Nov 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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