diff --git a/src/Scheduler.ts b/src/Scheduler.ts index a8969d133e..00e8fa0739 100644 --- a/src/Scheduler.ts +++ b/src/Scheduler.ts @@ -3,7 +3,7 @@ import {Action} from './scheduler/Action'; export interface Scheduler { now(): number; - schedule(work: (state?: any) => Subscription | void, delay?: number, state?: any): Subscription; + schedule(work: (state?: T) => Subscription | void, delay?: number, state?: T): Subscription; flush(): void; active: boolean; actions: Action[]; diff --git a/src/scheduler/AnimationFrameAction.ts b/src/scheduler/AnimationFrameAction.ts index 410db9a566..4a391e643f 100644 --- a/src/scheduler/AnimationFrameAction.ts +++ b/src/scheduler/AnimationFrameAction.ts @@ -4,7 +4,7 @@ import {AnimationFrame} from '../util/AnimationFrame'; export class AnimationFrameAction extends FutureAction { - protected _schedule(state?: any, delay: number = 0): Action { + protected _schedule(state?: T, delay: number = 0): Action { if (delay > 0) { return super._schedule(state, delay); } diff --git a/src/scheduler/AnimationFrameScheduler.ts b/src/scheduler/AnimationFrameScheduler.ts index 5949db18fc..28beffd71c 100644 --- a/src/scheduler/AnimationFrameScheduler.ts +++ b/src/scheduler/AnimationFrameScheduler.ts @@ -4,7 +4,7 @@ import {QueueScheduler} from './QueueScheduler'; import {AnimationFrameAction} from './AnimationFrameAction'; export class AnimationFrameScheduler extends QueueScheduler { - scheduleNow(work: (x?: any) => Subscription, state?: any): Action { + scheduleNow(work: (x?: T) => Subscription, state?: T): Action { return new AnimationFrameAction(this, work).schedule(state); } } diff --git a/src/scheduler/AsapAction.ts b/src/scheduler/AsapAction.ts index c800722ae4..85f2eb23bc 100644 --- a/src/scheduler/AsapAction.ts +++ b/src/scheduler/AsapAction.ts @@ -4,7 +4,7 @@ import {FutureAction} from './FutureAction'; export class AsapAction extends FutureAction { - protected _schedule(state?: any, delay: number = 0): Action { + protected _schedule(state?: T, delay: number = 0): Action { if (delay > 0) { return super._schedule(state, delay); } diff --git a/src/scheduler/AsapScheduler.ts b/src/scheduler/AsapScheduler.ts index e511b2a243..e829628c5c 100644 --- a/src/scheduler/AsapScheduler.ts +++ b/src/scheduler/AsapScheduler.ts @@ -4,7 +4,7 @@ import {Subscription} from '../Subscription'; import {QueueScheduler} from './QueueScheduler'; export class AsapScheduler extends QueueScheduler { - scheduleNow(work: (x?: any) => Subscription, state?: any): Action { + scheduleNow(work: (x?: T) => Subscription, state?: T): Action { return new AsapAction(this, work).schedule(state); } } diff --git a/src/scheduler/FutureAction.ts b/src/scheduler/FutureAction.ts index 6341f0ed79..819b891854 100644 --- a/src/scheduler/FutureAction.ts +++ b/src/scheduler/FutureAction.ts @@ -5,12 +5,12 @@ import {Subscription} from '../Subscription'; export class FutureAction extends Subscription implements Action { - public id: any; - public state: any; + public id: number; + public state: T; public delay: number; constructor(public scheduler: Scheduler, - public work: (x?: any) => Subscription | void) { + public work: (x?: T) => Subscription | void) { super(); } @@ -21,21 +21,21 @@ export class FutureAction extends Subscription implements Action { this.work(this.state); } - schedule(state?: any, delay: number = 0): Action { + schedule(state?: T, delay: number = 0): Action { if (this.isUnsubscribed) { return this; } return this._schedule(state, delay); } - protected _schedule(state?: any, delay: number = 0): Action { + protected _schedule(state?: T, delay: number = 0): Action { this.delay = delay; this.state = state; const id = this.id; if (id != null) { - this.id = undefined; + this.id = null; root.clearTimeout(id); } diff --git a/src/scheduler/QueueAction.ts b/src/scheduler/QueueAction.ts index 0ff08df141..bb89bb12f3 100644 --- a/src/scheduler/QueueAction.ts +++ b/src/scheduler/QueueAction.ts @@ -2,7 +2,7 @@ import {Action} from './Action'; import {FutureAction} from './FutureAction'; export class QueueAction extends FutureAction { - protected _schedule(state?: any, delay: number = 0): Action { + protected _schedule(state?: T, delay: number = 0): Action { if (delay > 0) { return super._schedule(state, delay); } diff --git a/src/scheduler/QueueScheduler.ts b/src/scheduler/QueueScheduler.ts index efbf131632..c9e3a52efc 100644 --- a/src/scheduler/QueueScheduler.ts +++ b/src/scheduler/QueueScheduler.ts @@ -25,17 +25,17 @@ export class QueueScheduler implements Scheduler { this.active = false; } - schedule(work: (x?: any) => Subscription | void, delay: number = 0, state?: any): Subscription { + schedule(work: (x?: T) => Subscription | void, delay: number = 0, state?: T): Subscription { return (delay <= 0) ? this.scheduleNow(work, state) : this.scheduleLater(work, delay, state); } - scheduleNow(work: (x?: any) => Subscription | void, state?: any): Action { + scheduleNow(work: (x?: T) => Subscription | void, state?: T): Action { return new QueueAction(this, work).schedule(state); } - scheduleLater(work: (x?: any) => Subscription | void, delay: number, state?: any): Action { + scheduleLater(work: (x?: T) => Subscription | void, delay: number, state?: T): Action { return new FutureAction(this, work).schedule(state, delay); } } diff --git a/src/scheduler/VirtualTimeScheduler.ts b/src/scheduler/VirtualTimeScheduler.ts index 70ad646eef..f1653475d3 100644 --- a/src/scheduler/VirtualTimeScheduler.ts +++ b/src/scheduler/VirtualTimeScheduler.ts @@ -55,24 +55,24 @@ export class VirtualTimeScheduler implements Scheduler { }); } - schedule(work: (x?: any) => Subscription | void, delay: number = 0, state?: any): Subscription { + schedule(work: (x?: T) => Subscription | void, delay: number = 0, state?: T): Subscription { this.sorted = false; return new VirtualAction(this, work, this.index++).schedule(state, delay); } } class VirtualAction extends Subscription implements Action { - state: any; + state: T; delay: number; calls = 0; constructor(public scheduler: VirtualTimeScheduler, - public work: (x?: any) => Subscription | void, + public work: (x?: T) => Subscription | void, public index: number) { super(); } - schedule(state?: any, delay: number = 0): VirtualAction { + schedule(state?: T, delay: number = 0): VirtualAction { if (this.isUnsubscribed) { return this; }