[Fixed] RxJS – Multiple sources for .withLatestFrom


I want to merge the latest emitted values from multiple Observables, so right now I’m using .withLatestFrom. Except, it nests the data together in nested arrays instead of pushing the data into a new array value. Example code below.

Any ideas on how I can retrieve multiple Observable emits using .withLatestFrom?

  .map((data) => { console.log(data) });


withLatestFrom supports multiple observables:

.withLatestFrom(source1, source2, source3)
.map((data) => { console.log(data) });

-> [val, value1, value2, value3]

It also supports function as it’s last parameter, so you can get values other than arrays:

    .withLatestFrom(source1, source2, (val, one, two) => {
        return {val: val, one: one, two: two};

Leave a Reply

(*) Required, Your email will not be published