Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / src / internal / util / subscribeToObservable.ts
1 import { Subscriber } from '../Subscriber';
2 import { observable as Symbol_observable } from '../symbol/observable';
3
4 /**
5  * Subscribes to an object that implements Symbol.observable with the given
6  * Subscriber.
7  * @param obj An object that implements Symbol.observable
8  */
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');
14   } else {
15     return obs.subscribe(subscriber);
16   }
17 };