feat: Actions::tickingPromise

This commit is contained in:
cha0s 2019-09-08 07:39:55 -05:00
parent 708c4fe25d
commit 3296f3d196

View File

@ -113,21 +113,25 @@ export class Actions extends decorate(Traversals) {
}
serial(context) {
// Do a "dry" tick.
// Immediate tick. Maybe we can avoid a promise?
this.tick(context, 0);
// If it's pending, we have to return a ticking promise.
if (this.pending) {
return new TickingPromise(
(resolve) => {
this.once('actionsFinished', () => {
resolve();
});
},
(elapsed) => {
this.tick(context, elapsed);
},
);
return this.tickingPromise(context);
}
}
tickingPromise(context) {
return new TickingPromise(
(resolve) => {
this.once('actionsFinished', () => {
resolve();
});
},
(elapsed) => {
this.tick(context, elapsed);
},
);
}
}