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
Adding operate #7264
Conversation
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
…eation + Adds `operate` + Adds destination override functionality to `Subscriber`. TODO: Documentation for `operate`.
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.
LcsGa
approved these changes
May 16, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
new Subscriber
now accepts anoverrides
argument as the second parameter. This argument contains the same set of arguments we used to pass tocreateOperatorSubscriber
. In short, passing innext
will "override"_next
,error
overrides_error
, etc.Subscriber
constructor has been re-deprecated (it's currently deprecated in 7.x). There's no reason anyone should be creating a subscriber instance withnew Subscriber
, really.Subscriber
constructer with 2 arguments is marked@internal
, and is not a public API.operate
has been added. This basically wraps the newSubscriber
constructor instance.createOperatorSubscriber(destination, next, complete, error, finalize)
tooperate({ destination, next, error, complete, finalize })
. That's it.createOperatorSubscriber
as a means of creating operator-relatedSubscriber
instances and subscribing to aSubject
with them.If it helps reviewers, I live-streamed the bulk of the work here: https://youtu.be/YHyt3fHIEAk
Subscriber
to accept the overrides work and explanation: https://youtu.be/YHyt3fHIEAk?t=475operate
function: https://youtu.be/YHyt3fHIEAk?t=1304Subscriber
signature type overloads: https://youtu.be/YHyt3fHIEAk?t=1491operate
: https://youtu.be/YHyt3fHIEAk?t=1718Subscriber
signatures (with dtslint testing): https://youtu.be/YHyt3fHIEAk?t=3420catchError
: https://youtu.be/YHyt3fHIEAk?t=4210takeLast
: https://youtu.be/YHyt3fHIEAk?t=4454finalize
override/handler is fired after the subscriber cleans up: https://youtu.be/YHyt3fHIEAk?t=6368