-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
Idea
Support converting objects that have a subscribe() method to Observables.
class SomeThingy<T> {
subscribe(observer: Observer<T>): { unsubscribe(): void } {
/// stuff here.
return {
unsubscribe() { }
};
}
}
const someThingy = new SomeThingy();
const anObservableOfSomeThingy$ = from(someThingy);History
Originally, we opted not to do this, because RxJS 4 and under had observers that required methods that were different. Like { onNext, onError, onComplete }, where we had { next, error, complete }. Now that new usership of RxJS 4 and under is down, and mixed usership of RxJS 7 and RxJS 4 and under is almost non-existent, I think we can consider doing this.
Issues
- There are lots of APIs in the world that have a
subscribefunction. Many of them take just a single function instead of an observer object. Can we support that too? or only Observer arguments? - We may at some point move to using
AbortSignalas the second argument tosubscribe, do we want to account for that now? We'd at least have to leave room. - Do we support returns of
voidor only if they return anUnsubscribable? - Should it just be a "from" helper?
fromSubscribable?
Other things
This isn't a "for sure" plan. Thus far we haven't had much need or many requests for this feature. I just think it's time to consider it.
samal-rasmussen
Metadata
Metadata
Assignees
Labels
No labels