I thought I understood the difference between a cold and a hot Observed, but something seems to be slipping away from me. This code works as expected:
var obs = Rx.Observable.interval(2000);
var A = obs.subscribe(function(value) { console.log('A', value) });
var B = obs.subscribe(function(value) { console.log('B', value) });
With this, I get the following result:
A 0
B 0
A 1
B 1
...
But when I add flatMapto retrieve the remote JSONP resource:
var obs = Rx.Observable.interval(2000).flatMap(function() {
return Rx.DOM.jsonpRequest({ url: URL });
})
.map(function(value) { return value.prop; });
var A = obs.subscribe(function(value) { console.log('A', value) });
var B = obs.subscribe(function(value) { console.log('B', value) });
I get only Alogs:
A prop
A prop
A prop
...
If you turn Observable into hot using publish().refCount(), it works as I would expect both subscribers to get the same values.
Now I realize that by observing that it is cold, I do not expect to get the same value at the same time, but I would expect that both the observer Aand Breceive values rather than only A.
What am I missing here?