source: trip-planner-front/node_modules/rxjs/src/internal/util/toSubscriber.ts@ 571e0df

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

initial commit

  • Property mode set to 100644
File size: 779 bytes
Line 
1import { Subscriber } from '../Subscriber';
2import { rxSubscriber as rxSubscriberSymbol } from '../symbol/rxSubscriber';
3import { empty as emptyObserver } from '../Observer';
4import { PartialObserver } from '../types';
5
6export function toSubscriber<T>(
7 nextOrObserver?: PartialObserver<T> | ((value: T) => void),
8 error?: (error: any) => void,
9 complete?: () => void): Subscriber<T> {
10
11 if (nextOrObserver) {
12 if (nextOrObserver instanceof Subscriber) {
13 return (<Subscriber<T>> nextOrObserver);
14 }
15
16 if (nextOrObserver[rxSubscriberSymbol]) {
17 return nextOrObserver[rxSubscriberSymbol]();
18 }
19 }
20
21 if (!nextOrObserver && !error && !complete) {
22 return new Subscriber(emptyObserver);
23 }
24
25 return new Subscriber(nextOrObserver, error, complete);
26}
Note: See TracBrowser for help on using the repository browser.