-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOM: Reorder Observable completion events
This CL "fixes" Observable unsubscription/teardown timing. As a matter of accidental historical precedent, Observables in JavaScript (but not in other languages) had implemented the "rule" that upon Subscriber#error() or Subscriber#complete(), the subscriber would: 1. First, invoke the appropriate Observer callback, if provided (i.e., complete() or error() callback). 2. Signal abort Subscriber#signal, which invokes any teardowns and also fires the `abort` event at the signal. However, after dom@chromium.org discussed this more with ben@benlesh.com, we came to the conclusion that the principle of "as soon as you know you will teardown, you MUST close the subscription and any upstream subscriptions" should be adhered. This means the above steps must be inverted. This is a small-in-size but medium-in-impact design change for the Observable concept, and led to a blog post [1] and an announcement [2] that the RxJS library intends to change its historical ordering of these events. This CL: 1. Inverts the order of the aforementioned steps in the Blink implementation. 2. Improves some tests that assert this new ordering. 3. Simplifies the takeUntil() operator in general. The Observable spec will be updated alongside this commit: WICG/observable#120. [1]: https://benlesh.com/posts/observables-are-broken-and-so-is-javascript/ [2]: ReactiveX/rxjs#7443 R=masonf@chromium.org Bug: 1485981 Change-Id: I376e66eef490808d264dc999862a801d591aa278 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5311097 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1263562}
- Loading branch information
1 parent
92bd007
commit 0f47956
Showing
2 changed files
with
108 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters