-
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
FromObservable should except all subscribables #1980
Comments
I believe at some point the implementation changed to accept objects with a |
@trxcllnt is correct. Any type that wants interop only needs to implement |
If I had to guess, I'd say the real ask here is that we support interop with previous versions of RxJS. This can get a little cumbersome, where it would be easier to patch Rx4 observables to support Rx4.Observable.prototype[Symbol.observable] = () => {
return new Rx5.Observable(observer => {
const disposable = this.subscribe({
destination: observer,
onNext(x) { this.destination.next(x); },
onError(err) { this.destination.error(err); },
onCompleted() { this.destination.complete(); }
});
return () => disposable.dispose();
});
} I think I'm going to close this issue for now. If there are any major objections, I'm happy to reopen. |
This stems from a conversation with @jayphelps here while working on some redux-obserable stuff. My issue is with the docs not matching the source. The docs here say any object that is Yes, Rx4 did work like this, but I understand the reasoning behind not doing things the same way. But that still means the docs are not correct and should reflect that only observables that implement the observable interface work with the fromObservable operator. |
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
In the docs for FromObserable it state that the Observable excepts anything subscribable.
However, the implementation expects something that is subscribable to actually be either an Array, Promise, Iterator, or an pass instanceof Observable check. This means that something that is subscribable but is not an instance of Observable will throw an error.
See: https://github.com/ReactiveX/rxjs/blob/master/src/observable/FromObservable.ts#L82-L95
The solution. Allow anything with a subscribe method to be wrapped in a proper Observable or change the docs to reflect the implementation.
The text was updated successfully, but these errors were encountered: