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()
=====这样很麻烦,使用引用计数 来自动connect unconnect====
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()
=======省略的写法========
//需要手动的去connect
//需要手动去unsubscribe unconnect
=====这样很麻烦,使用引用计数 来自动connect unconnect====
->进一步省略