-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add subscription
as secondary argument to next handlers for Observers
#3983
Comments
Any thoughts on how operators that accept an Observer like It seems like a footgun to provide the subscription to Observers provided to rough TypeScript Playground example You're probably proposing that Observer's interface stays the same, but that |
range(0, Number.POSITIVE_INFINITY).pipe(
tap(function (value) {
console.log(value);
if (value >= 3) this.unsubscribe();
})
).subscribe(); Given that, I think it's probably best to keep it congruent with Subjects thoSubjects are another thing to think about. It doesn't make sense to require that |
Is that intentional or just incidental from sharing code? I'm personally against it, but it's not a huge deal, just a footgun IMO. |
Intentional. |
Note from core team meeting: We might want it to be a |
Does it really, as in this has been explicitly designed this way? I would've assumed this was just an unintended coincidence.
That's not the kind of argument a non-core team member could ever make to get something approved :-) My question is: what are such fire hoses useful for? Seems like this is just a "reactive" way of creating a specific array, which to me sounds like something that could be handled entirely outside rxjs, and then be passed to |
Such hoses are useful for unit tests. |
I think we can close this, general lack of interest. |
Currently, you can get a hold of the subscription in an Observer or next handler via the
this
context:Most people aren't aware of this feature or why it exists. It exists for the reason you see above. If you have a synchronous fire hose of values, you need some way to shut it off, and you don't have a handle to the subscription beforehand. If you use a non-arrow function here, you can use
this
to get at theunsubscribe
and tear down if necessary.It's cool, but not intuitive
Proposal
Add
subscribe
as the second argument to next handlers passed to subscribe.The text was updated successfully, but these errors were encountered: