diff --git a/src/Observer.ts b/src/Observer.ts index 8346678e53..0f990018b3 100644 --- a/src/Observer.ts +++ b/src/Observer.ts @@ -1,6 +1,6 @@ export interface Observer { - next(value: T): void; - error(err?: any): void; - complete(): void; - isUnsubscribed: boolean; + next?: (value: T) => void; + error?: (err?: any) => void; + complete?: () => void; + isUnsubscribed?: boolean; } \ No newline at end of file diff --git a/src/Subscriber.ts b/src/Subscriber.ts index aa97457077..e780f0ba03 100644 --- a/src/Subscriber.ts +++ b/src/Subscriber.ts @@ -83,15 +83,24 @@ export class Subscriber extends Subscription implements Observer { } _next(value: T): void { - this.destination.next(value); + const destination = this.destination; + if (destination.next) { + destination.next(value); + } } _error(err: any): void { - this.destination.error(err); + const destination = this.destination; + if (destination.error) { + destination.error(err); + } } _complete(): void { - this.destination.complete(); + const destination = this.destination; + if (destination.complete) { + destination.complete(); + } } next(value?: T): void {