What is going on with the concat
call? I know that if I replace concat
by merge
the code works correctly and the output is foo
bar
qux
quux
. I've read about Hot and Cold observables, and I know that for hot observables that might happen if the values are generated before the subscription, but my observables down there are cold, so I guess that's not the case.
const Rx = require('rxjs');
const observable1 = Rx.Observable.create((observer) => {
observer.next('foo');
observer.next('bar');
return observer;
});
const observable2 = Rx.Observable.create((observer) => {
observer.next('qux');
observer.next('quux');
return observer;
});
const result1 = observable1.concat(observable2);
result1.subscribe((x) => console.log(x));
// outputs
foo
bar
https://codepen.io/thiagoh/pen/WZyrRL
I believe observer1 needs to complete()
, then concat can start outputting observer2.
Ammended CodePen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With