-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Observable constructor doesn't require any parameter #3153
Comments
If I recall correctly, this was due to signature incompatibility with Subejct as same as signature of static |
I still have to check once again and see if that's true though. |
So at the end this might be related to this: #2004 |
I checked it again today with |
RxJS version: 5.5.3
Code to reproduce:
Expected behavior:
Throw compilation error or run fine and do nothing.
Actual behavior:
Compiles fine but throws error when run.
Additional information:
I've seen this question on StackOverflow at least three times where people misunderstood the difference between Subject and Observable classes. They created an instance of Observable and then didn't know what to do next.
What's confusing is that you can create an Observable with just
new Observable()
(orObservable.create()
) because thesubscribe
callback is optional but when they try to subscribe it throws an error:The error is thrown because this line by default checks if
this.source
exists:but then it tries to use
this.source
anyway:So maybe the constructor should require either the
subscribe
callback or asource
to be always set. For example like this:The text was updated successfully, but these errors were encountered: