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