0
votes

This code logs different result for RxJS 4 and RxJS 5

Rx.Observable.merge( Rx.Observable.from([1,2,3,4]), Rx.Observable.from([5,6,7]) ).subscribe(i => console.log(i))

Result for RxJS 4: 1,5,2,6,3,7,4 - the result is correct according to the docs of merge:

Creates an output Observable which concurrently emits all values from every given input Observable

RxJS5: 1,2,3,4,5,6,7 - result is the same as from concat operator that is not as described in docs

So how to get the values from two array observables concurrently in RxJS5?

1
You are passing synchronous observables. For an explanation of what's happening, see: staltz.com/primer-on-rxjs-schedulers.htmlcartant
And for the v4 and v5 scheduling differences see: github.com/ReactiveX/rxjs/blob/master/…cartant

1 Answers

0
votes

Thanks to cartant.

The proper solution in RxJS 5:

Rx.Observable.merge( Rx.Observable.from([1,2,3,4], Rx.Scheduler.asap), Rx.Observable.from([5,6,7], Rx.Scheduler.asap) ).subscribe(i => console.log(i))