rxjs: Rx.Observable.merge is not accepting Array of Observables
Given:
const name$ = Rx.Observable.merge([
Rx.Observable.of('Bruce Lee'),
Rx.Observable.of('Brad Pitt'),
]);
Above code will return as a nested Observable. But if I remove the square bracket it works as expected.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 5
- Comments: 18 (6 by maintainers)
mergedoesn’t currently accept an array, it only acceptsrestargs. The work around is to use the...operator.and
I think this is one of the cases for a static
mergeAllwhich I’ve proposed elsewhere #786If you’re using Babel or TypeScript, for now you can just do:
Why was this closed and marked as fixed? @benlesh I’m using the
...operator as a workaround, and not really a big deal, but it isn’t “fixed”.This as been fixed.
I have the same issue here. I build up an array of observables which do, lets say install steps, then I merge them with Observable merge. And then I got the same behaviour.
I must be doing something wrong
I get subscribe is not a function. No idea what’s up with that. Anyone see the same? I also tried calling do() on the result of merge, same thing:
TypeError: Rx.Observable.merge(...).do is not a functionWeird.
@blesh I don’t think this has been fixed. In RC1 passing an array into merge still returns a nested Observable as stated in the original issue.
@blesh Not seeing the fix in beta10, also not as a function signature in the merge.d.ts. Can’t seem to find a linked commit… Am I overlooking something?
I’m currently experiencing the same issue…Though, my
complete()method also does not fire.That being said, adding the
...before the array variable name being passed intomergeas mentioned by @blesh does make it work.@blesh was a static operator added? The other closed issue referred back to this one. 😃