Use Promise.then(f) instead of setTimeout(f, 0)
This commit is contained in:
parent
491b97e3d9
commit
f7622708a1
|
@ -12,12 +12,17 @@ function Ground(bootProc) {
|
||||||
this.backgroundTaskCount = 0;
|
this.backgroundTaskCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ground._resolved = Promise.resolve();
|
||||||
|
Ground.laterCall = function (thunk) {
|
||||||
|
Ground._resolved.then(thunk);
|
||||||
|
};
|
||||||
|
|
||||||
Ground.prototype.start = function () {
|
Ground.prototype.start = function () {
|
||||||
if (!this.stepperId) {
|
if (!this.stepperId) {
|
||||||
this.stepperId = setTimeout(() => {
|
this.stepperId = Ground.laterCall(() => {
|
||||||
this.stepperId = null;
|
this.stepperId = null;
|
||||||
this._step();
|
this._step();
|
||||||
}, 0);
|
});
|
||||||
}
|
}
|
||||||
return this; // allows chaining start() immediately after construction
|
return this; // allows chaining start() immediately after construction
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue