Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rx.Observable.merge seems to return an array not a new observable #26

Closed
ORESoftware opened this issue Jan 10, 2017 · 6 comments
Closed

Comments

@ORESoftware
Copy link

Not sure if this is a doc bug or library bug but

Rx.Observable.merge seems to return an array not a new observable

but the docs say:

signature: merge(input: Observable): Observable

Turn multiple observables into a single observable.
Rx.Observable.timer(1)

here is my proof:

screenshot from 2017-01-09 20-32-26

lastly I want to say thank you for these docs, hopefully I am right about this bug, and in that case very willing to tolerate a little bit of wonkiness for a bit, thanks

@btroncone
Copy link
Owner

Hello,

It looks like you are calling it wrong. merge takes a variable number of observables, not an array. Try calling it like this:

const example = Rx.Observable.of(
 Rx.Observable.timer(1),
 Rx.Observable.timer(1),
 Rx.Observable.timer(1)
)

This should give you the correct behavior. 👍

@ORESoftware
Copy link
Author

thanks! :) hate to beat a horse, but why not allow for an array as well? I am sure I am not the only one to make such a mistake or to make the same request!

@ORESoftware
Copy link
Author

oh duh, if you allow for an array, it will return an array. Ughhh I think it's bad the way it is.

Rx.Observable.merge or Rx.Observable.of should return the same type, no matter what the input.

Right now Rx.Observable.merge will return an array, if an array is passed to it, and an Observable otherwise, that's pretty craytown TBH

@btroncone
Copy link
Owner

I agree the behavior seems a little strange. I cannot speak to the intentions though, for that you will need to open up a ticket on official RxJS repo. Feel free to post a link here if you do. 👍

@ORESoftware
Copy link
Author

ORESoftware commented Jan 12, 2017

yeah thanks; I think in general with statically typed languages you can have overloaded functions/methods that return different types based off the input type, but with JS and no real overloaded methods/functions, it sure would make things easier if methods/functions always returned the same type

@ORESoftware
Copy link
Author

I did submit an issue, we will see what they say

ReactiveX/rxjs#2274

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants