1 import { Subscriber } from '../Subscriber';
2 import { observable as Symbol_observable } from '../symbol/observable';
5 * Subscribes to an object that implements Symbol.observable with the given
7 * @param obj An object that implements Symbol.observable
9 export const subscribeToObservable = <T>(obj: any) => (subscriber: Subscriber<T>) => {
10 const obs = obj[Symbol_observable]();
11 if (typeof obs.subscribe !== 'function') {
12 // Should be caught by observable subscribe function error handling.
13 throw new TypeError('Provided object does not correctly implement Symbol.observable');
15 return obs.subscribe(subscriber);