-
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
SwitchAll / SwitchLatest are broken #302
Comments
Thank you for pointing this out. Looking into this and expanding tests uncovered a variety of anomalies. I've been heads down refactoring code in this area. |
I think it solves one of the problem. var Rx = require("./cjs/Rx");
var Observable = Rx.Observable;
Observable.interval(1000).switchLatest(function(i) {
return Observable.interval(100).map(function(j) {
console.log("inner", i + "_" + j);
return i + "_" + j;
});
}).subscribe(function(v) {
console.log("outer", v);
}); Outer subscription behaves as expected now:
However, the inner subscriptions (from the map operator in my example) do not seem to be cleaned up. The "inner interval" side effects are still present. It looks like the subscription graph is not entirely disposed as it should be, causing a leak:
Not sure if this problem is linked to the |
Returning subscriptions from the project function in the operator doesn't do anything special. They're not being cleaned up because you're creating new subscriptions and never unsubscribing therm. I'm actually amazed that worked at all. I'll check that out. |
Thanks !
I'm not sure I understand correctly your comment. |
@Blesh the project function in this example isn't returning a Subscription, the outer subscribe call is just indented a bit. |
Sorry, I was looking at it from my phone before. Looked like it was all together on that little screen |
I see the problem... PR incoming |
(me thinking out loud) Could be interesting to find out how to simply test the unsubscription on inner side-effects... |
@jinroh this will require just a regular synchronous test. |
@jinroh you're absolutely right, marble diagrams will not fix this issue and I have said from the beginning that we need a hybrid approach with concrete numbers. For example, in RxJS the current version, we not only track the results, but also the subscriptions, which is not something the current implementation does. For example, with |
Marble diagrams are amazing/perfect for verifying sequences of notifications. What we need to add are the output of additional events that occur during the execution of the observable. Mostly just timings of inner subscriptions and unsubscriptions. |
switch
operators do not seem to unsubscribe properly their inner subscriptions.Here is a small repro code:
The text was updated successfully, but these errors were encountered: