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

DOM: Reorder Observable completion events #44682

Merged
merged 1 commit into from
Feb 21, 2024

Commits on Feb 21, 2024

  1. 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}
    domfarolino authored and chromium-wpt-export-bot committed Feb 21, 2024
    Configuration menu
    Copy the full SHA
    fc5d0d6 View commit details
    Browse the repository at this point in the history