I have two observables which I want to combine with combineLatest
:
const o1 = from(['a', 'b', 'c']);
const o2 = of('content from o2');
combineLatest(o1, o2)
.subscribe(result => console.log(result));
As I understood combineLatest
, when any observable emits, it will combine the latest values of all observables and emit them:
When any observable emits a value, emit the latest value from each. (https://www.learnrxjs.io/operators/combination/combinelatest.html)
However, with the code above, the output is:
["c", "content from o2"]
So only when o2
emits, combineLatest
emits an value.
If I switch the order I hand over o1
and o2
, it works as expected:
const o1 = from(['a', 'b', 'c']);
const o2 = of('content from o2');
combineLatest(o2, o1)
.subscribe(result => console.log(result));
Output:
["content from o2", "a"]
["content from o2", "b"]
["content from o2", "c"]
Is this expected behavior? If so, why? This seems to contradict the definition ob combineLatest
.