refactor: actionsFinished emit async

This commit is contained in:
cha0s 2019-04-20 16:02:52 -05:00
parent 2694e79240
commit 707fa2ec4d

View File

@ -17,6 +17,12 @@ export class Actions extends decorate(Traversals) {
this.pending = null;
}
emitFinishedAsync() {
setTimeout(() => {
this.emit('actionsFinished');
}, 0);
}
get index() {
return this._index;
}
@ -27,7 +33,7 @@ export class Actions extends decorate(Traversals) {
tick(context, elapsed) {
if (this.traversals.length === 0) {
this.emit('actionsFinished');
this.emitFinishedAsync();
return;
}
if (
@ -61,7 +67,7 @@ export class Actions extends decorate(Traversals) {
prologue() {
this.pending = null;
if (0 === (this.index = (this.index + 1) % this.traversals.length)) {
this.emit('actionsFinished');
this.emitFinishedAsync();
}
}