我找了很多资料都看的不是很明白,希望大家可以简单的说一说或者提供点资料,谢谢!
PHPz2017-04-11 12:16:56
var subject$$ = new Rx.ReplaySubject();
subject$$.subscribe( x => console.log('sub',x) );
var observableA$ = Rx.Observable.of('test');
observableA$.subscribe(subject$$) ;
var connectableObservable$ = Rx.Observable.of('test').multicast( new Rx.ReplaySubject())
//需要手动的去connect
var sub = connectableObservable$.connect();
connectableObservable$.subscribe( x => console.log('sub',x) );
//需要手动去unsubscribe unconnect
sub.unsubscribe()
var sourceA$ = connectableObservable$.refCount(); //stands for referenceCounting
var subA = sourceA$.subscribe( x => console.log('sub',x) )
//ref 0->1 then automatic connect
subA.unsubscribe()
//ref 1-> 0 then automatic unconnect
Rx.Observable.of('test').multicast( new Rx.ReplaySubject() ).refCount()
Rx.Observable.of('test').publishReplay().refCount()