diff --git a/src/operators/observeOn.ts b/src/operators/observeOn.ts index 9ecc63f08c..f16dd1b753 100644 --- a/src/operators/observeOn.ts +++ b/src/operators/observeOn.ts @@ -3,6 +3,7 @@ import Observer from '../Observer'; import Scheduler from '../Scheduler'; import Observable from '../Observable'; import Subscriber from '../Subscriber'; +import Notification from '../Notification'; export default function observeOn(scheduler: Scheduler, delay: number = 0): Observable { return this.lift(new ObserveOnOperator(scheduler, delay)); @@ -25,8 +26,8 @@ export class ObserveOnOperator implements Operator { export class ObserveOnSubscriber extends Subscriber { - static dispatch({ type, value, destination }) { - destination[type](value); + static dispatch({ notification, destination }) { + notification.observe(destination); } delay: number; @@ -40,33 +41,30 @@ export class ObserveOnSubscriber extends Subscriber { _next(x) { this.add(this.scheduler.schedule(this.delay, - new ScheduledNotification("next", x, this.destination), + new ObserveOnMessage(Notification.createNext(x), this.destination), ObserveOnSubscriber.dispatch) ); } _error(e) { this.add(this.scheduler.schedule(this.delay, - new ScheduledNotification("error", e, this.destination), + new ObserveOnMessage(Notification.createError(e), this.destination), ObserveOnSubscriber.dispatch)); } _complete() { this.add(this.scheduler.schedule(this.delay, - new ScheduledNotification("complete", void 0, this.destination), + new ObserveOnMessage(Notification.createComplete(), this.destination), ObserveOnSubscriber.dispatch)); } } -class ScheduledNotification { - - type: string; - value: any; +class ObserveOnMessage { + notification: Notification; destination: Observer; - - constructor(type: string, value: any, destination: Observer) { - this.type = type; - this.value = value; + + constructor(notification: Notification, destination:Observer) { + this.notification = notification; this.destination = destination; } } \ No newline at end of file