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

Fix finally to return Observable #49

Merged
merged 6 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ We propose the following operators in addition to the `Observable` interface:
until the input observable emits its first value
- `finally()`
- Like `Promise.finally()`, it takes a callback which gets fired after the
observable completes in any way (`complete()`/`error()`)
observable completes in any way (`complete()`/`error()`).
- Returns an `Observable` that mirrors the source observable exactly. The callback
passed to `finally` is fired when a subscription to the resulting observable is terminated
for _any reason_. Either immediately after the source completes or errors, or when the consumer
unsubscribes by aborting the subscription.

Versions of the above are often present in userland implementations of
observables as they are useful for observable-specific reasons, but in addition
Expand Down
9 changes: 7 additions & 2 deletions spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ interface Observable {
constructor(SubscribeCallback callback);
undefined subscribe(optional ObserverUnion observer = {}, optional SubscribeOptions options = {});

undefined finally(VoidFunction callback);

// Constructs a native Observable from value if it's any of the following:
// - Observable
// - AsyncIterable
Expand All @@ -354,6 +352,7 @@ interface Observable {
Observable take(unsigned long long amount);
Observable drop(unsigned long long amount);
Observable flatMap(Mapper mapper);
Observable finally(VoidFunction callback);

// Promise-returning operators.
Promise<sequence<any>> toArray(optional SubscribeOptions options = {});
Expand Down Expand Up @@ -688,6 +687,12 @@ For now, see [https://github.com/wicg/observable#operators](https://github.com/w
1. <span class=XXX>TODO: Spec this and use |mapper|.</span>
</div>

<div algorithm>
The <dfn for=Observable method><code>finally(|callback|)</code></dfn> method steps are:

1. <span class=XXX>TODO: Spec this and use |callback|.</span>
</div>


<h4 id=promise-returning-operators>{{Promise}}-returning operators</h4>

Expand Down
Loading