Skip to content

Commit

Permalink
Merge 565e55b into 72d96bb
Browse files Browse the repository at this point in the history
  • Loading branch information
Tetsuharu OHZEKI committed Mar 3, 2016
2 parents 72d96bb + 565e55b commit 1a06665
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/Scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Action} from './scheduler/Action';

export interface Scheduler {
now(): number;
schedule<T>(work: (state?: any) => Subscription | void, delay?: number, state?: any): Subscription;
schedule<T>(work: (state?: T) => Subscription | void, delay?: number, state?: T): Subscription;
flush(): void;
active: boolean;
actions: Action[];
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/AnimationFrameAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {AnimationFrame} from '../util/AnimationFrame';

export class AnimationFrameAction<T> extends FutureAction<T> {

protected _schedule(state?: any, delay: number = 0): Action {
protected _schedule(state?: T, delay: number = 0): Action {
if (delay > 0) {
return super._schedule(state, delay);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/AnimationFrameScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {QueueScheduler} from './QueueScheduler';
import {AnimationFrameAction} from './AnimationFrameAction';

export class AnimationFrameScheduler extends QueueScheduler {
scheduleNow<T>(work: (x?: any) => Subscription, state?: any): Action {
scheduleNow<T>(work: (x?: T) => Subscription, state?: T): Action {
return new AnimationFrameAction(this, work).schedule(state);
}
}
2 changes: 1 addition & 1 deletion src/scheduler/AsapAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {FutureAction} from './FutureAction';

export class AsapAction<T> extends FutureAction<T> {

protected _schedule(state?: any, delay: number = 0): Action {
protected _schedule(state?: T, delay: number = 0): Action {
if (delay > 0) {
return super._schedule(state, delay);
}
Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/AsapScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Subscription} from '../Subscription';
import {QueueScheduler} from './QueueScheduler';

export class AsapScheduler extends QueueScheduler {
scheduleNow<T>(work: (x?: any) => Subscription, state?: any): Action {
scheduleNow<T>(work: (x?: T) => Subscription, state?: T): Action {
return new AsapAction(this, work).schedule(state);
}
}
12 changes: 6 additions & 6 deletions src/scheduler/FutureAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import {Subscription} from '../Subscription';

export class FutureAction<T> 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();
}

Expand All @@ -21,21 +21,21 @@ export class FutureAction<T> 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);
}

Expand Down
2 changes: 1 addition & 1 deletion src/scheduler/QueueAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {Action} from './Action';
import {FutureAction} from './FutureAction';

export class QueueAction<T> extends FutureAction<T> {
protected _schedule(state?: any, delay: number = 0): Action {
protected _schedule(state?: T, delay: number = 0): Action {
if (delay > 0) {
return super._schedule(state, delay);
}
Expand Down
6 changes: 3 additions & 3 deletions src/scheduler/QueueScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ export class QueueScheduler implements Scheduler {
this.active = false;
}

schedule<T>(work: (x?: any) => Subscription | void, delay: number = 0, state?: any): Subscription {
schedule<T>(work: (x?: T) => Subscription | void, delay: number = 0, state?: T): Subscription {
return (delay <= 0) ?
this.scheduleNow(work, state) :
this.scheduleLater(work, delay, state);
}

scheduleNow<T>(work: (x?: any) => Subscription | void, state?: any): Action {
scheduleNow<T>(work: (x?: T) => Subscription | void, state?: T): Action {
return new QueueAction(this, work).schedule(state);
}

scheduleLater<T>(work: (x?: any) => Subscription | void, delay: number, state?: any): Action {
scheduleLater<T>(work: (x?: T) => Subscription | void, delay: number, state?: T): Action {
return new FutureAction(this, work).schedule(state, delay);
}
}
8 changes: 4 additions & 4 deletions src/scheduler/VirtualTimeScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,24 @@ export class VirtualTimeScheduler implements Scheduler {
});
}

schedule<T>(work: (x?: any) => Subscription | void, delay: number = 0, state?: any): Subscription {
schedule<T>(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<T> 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<T> {
schedule(state?: T, delay: number = 0): VirtualAction<T> {
if (this.isUnsubscribed) {
return this;
}
Expand Down

0 comments on commit 1a06665

Please sign in to comment.