RunOnceScheduler.isScheduled()

This commit is contained in:
isidor 2016-02-04 19:48:46 +01:00
parent 9bbd9d3b1a
commit efdfcf1f4c

View file

@ -529,7 +529,7 @@ export class RunOnceScheduler {
* Cancel current scheduled runner (if any). * Cancel current scheduled runner (if any).
*/ */
public cancel(): void { public cancel(): void {
if (this.timeoutToken !== -1) { if (this.isScheduled()) {
platform.clearTimeout(this.timeoutToken); platform.clearTimeout(this.timeoutToken);
this.timeoutToken = -1; this.timeoutToken = -1;
} }
@ -557,6 +557,13 @@ export class RunOnceScheduler {
this.timeoutToken = platform.setTimeout(this.timeoutHandler, this.timeout); this.timeoutToken = platform.setTimeout(this.timeoutHandler, this.timeout);
} }
/**
* Returns true if scheduled.
*/
public isScheduled(): boolean {
return this.timeoutToken !== -1;
}
private onTimeout() { private onTimeout() {
this.timeoutToken = -1; this.timeoutToken = -1;
if (this.runner) { if (this.runner) {