-
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
Fix groupBy() to use lift() #1128
Conversation
@staltz I'm not a fan of this breaking change as the inners should be independent of the outers which makes them more reliable as you pass the inners around for streaming purposes and to be weirdly affected by something upstream. It's best to be kept as it was in RxJS v4 cc @headinthebox |
@mattpodwysocki I can see what you're talking about, but I'm having a hard time coming up with example code that would do this without doing something obviously strange. |
Also, why wouldn't we terminate those groups if they couldn't possibly produce another value because the source was terminated? It sounds more like a bug than a feature, TBH. |
Perhaps a middle-ground would be to have the inner streams error when the upstream is unsubscribed with a custom error like |
@staltz ... this needs to be rebased before I can merge it. |
Rebased! :) |
@mattpodwysocki |
@staltz I know that's how Once For example, if you multicast a |
@trxcllnt well said, and exactly my concerns that I had, which is why inner independence was necessary. |
Does that apply also to RxJS 4 https://jsbin.com/pukeni/edit?js,console |
@staltz no, this not independent of the outer subscription, upon disposal, it still ensures that the window is eventually emptied and then it stops. |
0ef4864
to
f0ad32a
Compare
@Blesh @mattpodwysocki this PR is now safe to merge, I re-implemented the solution to keep it backwards-compatible as Matt wishes. We can/could postpone the discussion on subscription independence. The priority was to get |
@staltz To be fair, it was both @trxcllnt and myself who wanted to keep independence. Also, I don't see the tests associated with this to check for the independence of the inner from the outer such as these from |
The tests were not added in this PR because they are already there, I had ported them from RxJS 4 to this repo long ago. |
LGTM. |
@staltz ah, sorry about that. LGTM then! |
@@ -211,7 +211,7 @@ export class Observable<T> implements CoreOperators<T> { | |||
projectResult?: (x: T, y: any, ix: number, iy: number) => R, | |||
concurrent?: number) => Observable<R>; | |||
flatMapTo: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R, concurrent?: number) => Observable<R>; | |||
groupBy: <K, R>(keySelector: (value: T) => string, | |||
groupBy: <T, K, R>(keySelector: (value: T) => K, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add T
as function generic parameter? expect T
comes from generic type of Observable<T>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember TS was complaining and this solved it, but I can re-check.
@kwonoj I updated the TS typing issue that you pointed out. |
Thanks, change looks good to me too. |
:) Sorry @staltz, can you rebase this one? |
Add tests for Observable to verify that the most important codebase-wide features brought by the lift architecture are satisfied. Refers to discussion in ReactiveX#60.
Add test for groupBy() operator, to verify that it supports the composable lift architecture. Test for issue ReactiveX#1085.
Fix bug ReactiveX#1085 in which groupBy was not using lift(). Using lift() is critical to support the ubiquitous lift-based architecture in RxJS Next Resolves ReactiveX#1085.
Alright, done |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Addresses bug #1085.
BREAKING CHANGES:
groupBy() now unsubscribes all inner Observables when the outer
Observable is unsubscribed. This diverges from the behavior in RxJS 4,
where inner Observables continue even if the outer is unsubscribed.
RxJS 4 explicitly supports the "inners continue when outer is unsubscribed", see this test. @Blesh @trxcllnt @mattpodwysocki what do you think about the breaking change I'm proposing? It seems odd to me why shouldn't we dispose of inners. I don't know if and why there is anyone depending on this behavior.