`Defer` call multiple times
RxJS version: 5.4.3
Code to reproduce:
const { Observable } = require("rxjs");
let a, b, c;
a = Observable.of(1).do(() => console.log('start'));
b = Observable.merge(a, Observable.defer(() => {
console.log('get c');
return c;
}));
c = b.delay(1000);
b.subscribe(x => console.log('tick'));
Expected behavior:
After showing start and get c, it will show tick per second.
Actual behavior:
Showing a lot of start and get c (>100), then show tick per second as expected.
Additional information: the flow graph is like following:
a -> b -> c(delay 1s)
^ |
< - +
After reading #2542, I know what is going on. There are inner circular subscriptions in it. Adding .share() solve it.
But I still facing problem in unsubscribing it like that in #2542.
I think there should be some way to solve the circular unsubscription issue by mark and sweep on the dependency graph. Current implementation of unsubscription is --refCount and check, which is OK when the graph is a tree.
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.