example:
var s1 = Observable.of([1, 2, 3]);
var s2 = Observable.of([4, 5, 6]);
s1.merge(s2).subscribe(val => {
console.log(val);
})
I want to get [1,2,3,4,5,6]
instead of
[1,2,3]
[4,5,6]
example:
var s1 = Observable.of([1, 2, 3]);
var s2 = Observable.of([4, 5, 6]);
s1.merge(s2).subscribe(val => {
console.log(val);
})
I want to get [1,2,3,4,5,6]
instead of
[1,2,3]
[4,5,6]
Just instead of
Observable.of
useObservable.from
that takes as argument an array and reemits all its values:Maybe instead of
merge
you might want to preferconcat
but in this situation with plain arrays it'll give same results.This will give you:
If you want this as a single array you could append also
toArray()
operator. Btw, you could achieve the same withObservable.of
but you'd have to call it withObservable.of.call(...)
which is probably unnecessary complicated and it's easier to use justObservable.from()
.forkJoin
works wells, you just need to flatten the array of arrays :Output :
[1, 2, 3, 4, 5, 6]
Plunkr to demo : https://plnkr.co/edit/zah5XgErUmFAlMZZEu0k?p=preview
Maybe you could do this with List instead of Array:
and then