Skip to content

Commit

Permalink
fix(Observer): anonymous observers now allow missing handlers
Browse files Browse the repository at this point in the history
Errors were being thrown in situations where a handler was not present on a partial observer

fixes #723
  • Loading branch information
benlesh committed Nov 13, 2015
1 parent 490619b commit a11c763
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Observer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export interface Observer<T> {
next(value: T): void;
error(err?: any): void;
complete(): void;
isUnsubscribed: boolean;
next?: (value: T) => void;
error?: (err?: any) => void;
complete?: () => void;
isUnsubscribed?: boolean;
}
15 changes: 12 additions & 3 deletions src/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,24 @@ export class Subscriber<T> extends Subscription<T> implements Observer<T> {
}

_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 {
Expand Down

0 comments on commit a11c763

Please sign in to comment.