In RxJS 6, how do I import a static merge function for merging a list of Observables?
I want to be able to do:
const merged$ = merge( obs1$, obs2$, obs3$ );
I've tried:
import { merge } from 'rxjs/observable/merge';
and
import { merge } from 'rxjs/operators';
but neither seems to give me what I want.
We can use the concat operator to take multiple Observables and return a new Observable that sequentially emits values from each Observable that were passed in. It works by subscribing to them one at a time and merging the results in the output Observable.
mergeAll combines a number of inner observable streams and concurrently emits all values from every input stream. It's similar to merge, but instead of taking a set of streams directly as input, it takes an observable source that produces other streams (observables).
Importing has been made easy in RxJS 6:
import { merge } from 'rxjs';
You may want to read the official migration guide.
Another useful resource regarding importing in RxJS 6 is this talk by Ben Lesh who is the RxJS lead.
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