I'm struggling with something which I can't understand why it is happening .
Looking at this example :
const source = Rx.Observable.of(1).share();
source.subscribe(console.log); //1
source.subscribe(console.log); //1
This prints "1" twice. AFAIK share
looks at refCount
. But if we look at it - refcount
should be ZERO here :
const source = Rx.Observable.of(1).share();
source.subscribe(console.log);
^-- 1)refCount=1
2)value emitted - closing subscription ( complete)
3)refCount=0
source.subscribe(console.log);
^-- does refCount is 1 again or is it Zero ?
Also - Things get more complicated when the observer is not completed
const source = Rx.Observable.create((o)=>o.next(1)).share();
source.subscribe(console.log); //1
source.subscribe(console.log); //nothing
^This only yield one value
Question
Is my refCount observation was correct and why there are different results between the two examples ?