Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
779 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | import { Subscriber } from '../Subscriber';
|
---|
| 2 | import { rxSubscriber as rxSubscriberSymbol } from '../symbol/rxSubscriber';
|
---|
| 3 | import { empty as emptyObserver } from '../Observer';
|
---|
| 4 | import { PartialObserver } from '../types';
|
---|
| 5 |
|
---|
| 6 | export 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.