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
subscribe function. 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
AbortSignal as the second argument to subscribe, do we want to account for that now? We'd at least have to leave room.
- Do we support returns of
void or only if they return an Unsubscribable?
- 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.
Idea
Support converting objects that have a
subscribe()method to Observables.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
subscribefunction. Many of them take just a single function instead of an observer object. Can we support that too? or only Observer arguments?AbortSignalas the second argument tosubscribe, do we want to account for that now? We'd at least have to leave room.voidor only if they return anUnsubscribable?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.