Reputation: 440
My issue is not with having working code, but my solution to combining streams of arrays seems fragile and I am sure Rxjs has a better solution. The following is and example of what I have written:
var all$ = Rx.Observable.combineLatest(
basicArray$, fastArray$, slowArray$,
function(basic, fast, slow){
return basic.concat(fast).concat(slow);
});
My goal is three in -> one out and only when there all three are new.
Upvotes: 2
Views: 62
Reputation: 3114
Using a utility (like lodash's flatten
method), you can accomplish the same using the following:
var all$ = Rx.Observable.combineLatest(basicArray$, fastArray$, slowArray$)
.map(_.flatten);
Looking at your last comment, however, I don't think your code works as expected. The stream resulting from combineLatest
will emit a new item as soon as any of the streams emits.
Based on your description, the zip
operator might be more appropriate: https://github.com/Reactive-Extensions/RxJS/blob/master/doc/api/core/operators/zip.md
Upvotes: 1