From 3296f3d19634d780e43486b61aa186abc282f352 Mon Sep 17 00:00:00 2001 From: cha0s Date: Sun, 8 Sep 2019 07:39:55 -0500 Subject: [PATCH] feat: Actions::tickingPromise --- packages/behavior/item/actions.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/behavior/item/actions.js b/packages/behavior/item/actions.js index 98f80a9..1a9ceb2 100644 --- a/packages/behavior/item/actions.js +++ b/packages/behavior/item/actions.js @@ -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); + }, + ); + } + }