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

Adding operate #7264

Merged
merged 65 commits into from May 25, 2023
Merged

Adding operate #7264

merged 65 commits into from May 25, 2023

Conversation

benlesh
Copy link
Member

@benlesh benlesh commented May 16, 2023

This is the execution of the design from #7253.

Please review per commit.

The work here is broken into commits to help understand the changes.

The key bits of work are:

  1. new Subscriber now accepts an overrides argument as the second parameter. This argument contains the same set of arguments we used to pass to createOperatorSubscriber. In short, passing in next will "override" _next, error overrides _error, etc.
  2. Subscriber constructor has been re-deprecated (it's currently deprecated in 7.x). There's no reason anyone should be creating a subscriber instance with new Subscriber, really.
  3. The new Subscriber constructer with 2 arguments is marked @internal, and is not a public API.
  4. A publicly exposed function called operate has been added. This basically wraps the new Subscriber constructor instance.
  5. Operators were updated, one-by-one, in separate commits. There are no functional changes to these!!, all that was done was moving from createOperatorSubscriber(destination, next, complete, error, finalize) to operate({ destination, next, error, complete, finalize }). That's it.
  6. Only one test needed to be updated, and it was testing the createOperatorSubscriber as a means of creating operator-related Subscriber instances and subscribing to a Subject with them.

If it helps reviewers, I live-streamed the bulk of the work here: https://youtu.be/YHyt3fHIEAk

benlesh added 19 commits May 16, 2023 09:24
Note that this removes setting `destination` to `null`. We're doing this because code will want to unsubscribe from upstream, and _then_ send an error to downstream. This is per operator development guidelines.

Additional context: Since we are closing over `destination` in the `OperatorSubscriber` overrides, nulling out the `destination` in `Subscriber` literally never made a difference in memory, as the `destination` was trapped in memory by closer anyhow. Therefor the change to remove `this.destination = null!;` is no change at all.
Updates changes to `Subscription` to ensure that the `onFinalize` handler happens _after_ other finalization. This is to match previous behavior.
Also orders arguments in idiomatically: next, error, complete, finalize.
@benlesh benlesh marked this pull request as ready for review May 16, 2023 19:53
spec/Subscriber-spec.ts Outdated Show resolved Hide resolved
src/internal/Subscriber.ts Outdated Show resolved Hide resolved
src/internal/Subscriber.ts Show resolved Hide resolved
spec/Subscriber-spec.ts Show resolved Hide resolved
@benlesh benlesh merged commit 8e86624 into ReactiveX:master May 25, 2023
3 checks passed
@benlesh benlesh deleted the operate branch May 25, 2023 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants