diff --git a/src/operator/delay.ts b/src/operator/delay.ts index e2bfbdb41b..b52f561e6e 100644 --- a/src/operator/delay.ts +++ b/src/operator/delay.ts @@ -3,8 +3,10 @@ import { isDate } from '../util/isDate'; import { Operator } from '../Operator'; import { IScheduler } from '../Scheduler'; import { Subscriber } from '../Subscriber'; +import { Action } from '../scheduler/Action'; import { Notification } from '../Notification'; import { Observable } from '../Observable'; +import { PartialObserver } from '../Observer'; import { TeardownLogic } from '../Subscription'; /** @@ -63,17 +65,23 @@ class DelayOperator implements Operator { } } +interface DelayState { + source: DelaySubscriber; + destination: PartialObserver; + scheduler: IScheduler; +} + /** * We need this JSDoc comment for affecting ESDoc. * @ignore * @extends {Ignored} */ class DelaySubscriber extends Subscriber { - private queue: Array = []; + private queue: Array> = []; private active: boolean = false; private errored: boolean = false; - private static dispatch(state: any): void { + private static dispatch(this: Action>, state: DelayState): void { const source = state.source; const queue = source.queue; const scheduler = state.scheduler; @@ -85,7 +93,7 @@ class DelaySubscriber extends Subscriber { if (queue.length > 0) { const delay = Math.max(0, queue[0].time - scheduler.now()); - ( this).schedule(state, delay); + this.schedule(state, delay); } else { source.active = false; } @@ -99,12 +107,12 @@ class DelaySubscriber extends Subscriber { private _schedule(scheduler: IScheduler): void { this.active = true; - this.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, { + this.add(scheduler.schedule>(DelaySubscriber.dispatch, this.delay, { source: this, destination: this.destination, scheduler: scheduler })); } - private scheduleNotification(notification: Notification): void { + private scheduleNotification(notification: Notification): void { if (this.errored === true) { return; } @@ -134,7 +142,7 @@ class DelaySubscriber extends Subscriber { } class DelayMessage { - constructor(private time: number, - private notification: any) { + constructor(public readonly time: number, + public readonly notification: Notification) { } }