source: trip-planner-front/node_modules/rxjs/src/internal/util/subscribeToObservable.ts@ 8d391a1

Last change on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 666 bytes
Line 
1import { Subscriber } from '../Subscriber';
2import { 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 */
9export 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};
Note: See TracBrowser for help on using the repository browser.