2

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.

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

.zip makes sense in making a better solution. Thank you for that feedback

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.