diff --git a/spec/schedulers/VirtualTimeScheduler-spec.ts b/spec/schedulers/VirtualTimeScheduler-spec.ts index 9c73ac84b1..6af1fe5e96 100644 --- a/spec/schedulers/VirtualTimeScheduler-spec.ts +++ b/spec/schedulers/VirtualTimeScheduler-spec.ts @@ -1,5 +1,6 @@ import {expect} from 'chai'; import * as Rx from '../../dist/cjs/Rx'; +import { VirtualAction } from '../../dist/cjs/scheduler/VirtualTimeScheduler'; const VirtualTimeScheduler = Rx.VirtualTimeScheduler; @@ -68,7 +69,7 @@ describe('VirtualTimeScheduler', () => { let count = 0; const expected = [100, 200, 300]; - v.schedule(function(state) { + v.schedule(function(this: VirtualAction, state: string) { if (++count === 3) { return; } diff --git a/src/Scheduler.ts b/src/Scheduler.ts index d7ba496766..e1e27ec73f 100644 --- a/src/Scheduler.ts +++ b/src/Scheduler.ts @@ -53,7 +53,7 @@ export class Scheduler { * @return {Subscription} A subscription in order to be able to unsubscribe * the scheduled work. */ - public schedule(work: (state?: T) => void, delay: number = 0, state?: T): Subscription { + public schedule(work: (this: Action, state?: T) => void, delay: number = 0, state?: T): Subscription { return new this.SchedulerAction(this, work).schedule(state, delay); } } diff --git a/src/scheduler/Action.ts b/src/scheduler/Action.ts index 57b3789bb6..1946b1b444 100644 --- a/src/scheduler/Action.ts +++ b/src/scheduler/Action.ts @@ -16,7 +16,7 @@ import { Subscription } from '../Subscription'; * @class Action */ export class Action extends Subscription { - constructor(scheduler: Scheduler, work: (state?: T) => void) { + constructor(scheduler: Scheduler, work: (this: Action, state?: T) => void) { super(); } /** diff --git a/src/scheduler/AnimationFrameAction.ts b/src/scheduler/AnimationFrameAction.ts index c9dfee0569..7bf440d5da 100644 --- a/src/scheduler/AnimationFrameAction.ts +++ b/src/scheduler/AnimationFrameAction.ts @@ -10,7 +10,7 @@ import { AnimationFrameScheduler } from './AnimationFrameScheduler'; export class AnimationFrameAction extends AsyncAction { constructor(protected scheduler: AnimationFrameScheduler, - protected work: (state?: T) => void) { + protected work: (this: AnimationFrameAction, state?: T) => void) { super(scheduler, work); } diff --git a/src/scheduler/AsapAction.ts b/src/scheduler/AsapAction.ts index ebfca01be9..fd0a8aec66 100644 --- a/src/scheduler/AsapAction.ts +++ b/src/scheduler/AsapAction.ts @@ -10,7 +10,7 @@ import { AsapScheduler } from './AsapScheduler'; export class AsapAction extends AsyncAction { constructor(protected scheduler: AsapScheduler, - protected work: (state?: T) => void) { + protected work: (this: AsapAction, state?: T) => void) { super(scheduler, work); } diff --git a/src/scheduler/AsyncAction.ts b/src/scheduler/AsyncAction.ts index 98b422d870..5610c1a537 100644 --- a/src/scheduler/AsyncAction.ts +++ b/src/scheduler/AsyncAction.ts @@ -16,7 +16,7 @@ export class AsyncAction extends Action { protected pending: boolean = false; constructor(protected scheduler: AsyncScheduler, - protected work: (state?: T) => void) { + protected work: (this: AsyncAction, state?: T) => void) { super(scheduler, work); } diff --git a/src/scheduler/QueueAction.ts b/src/scheduler/QueueAction.ts index 8b870f1fe4..23203b90ab 100644 --- a/src/scheduler/QueueAction.ts +++ b/src/scheduler/QueueAction.ts @@ -10,7 +10,7 @@ import { QueueScheduler } from './QueueScheduler'; export class QueueAction extends AsyncAction { constructor(protected scheduler: QueueScheduler, - protected work: (state?: T) => void) { + protected work: (this: QueueAction, state?: T) => void) { super(scheduler, work); } diff --git a/src/scheduler/VirtualTimeScheduler.ts b/src/scheduler/VirtualTimeScheduler.ts index 9712c400e5..21279b9696 100644 --- a/src/scheduler/VirtualTimeScheduler.ts +++ b/src/scheduler/VirtualTimeScheduler.ts @@ -47,7 +47,7 @@ export class VirtualTimeScheduler extends AsyncScheduler { export class VirtualAction extends AsyncAction { constructor(protected scheduler: VirtualTimeScheduler, - protected work: (state?: T) => void, + protected work: (this: VirtualAction, state?: T) => void, protected index: number = scheduler.index += 1) { super(scheduler, work); this.index = scheduler.index = index;