From b9d2bc80617b5596867b3555b39a31fe417537b9 Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Thu, 27 Apr 2017 02:47:00 -0700 Subject: [PATCH] fix(AsyncAction): Make AsyncAction update its timeout if rescheduled before its executed. Rescheduling an async action with the same due time before its executed should cause it to cancel its current interval and schedule a new one. 2579 --- src/scheduler/AsyncAction.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scheduler/AsyncAction.ts b/src/scheduler/AsyncAction.ts index 5610c1a537..891dc991b1 100644 --- a/src/scheduler/AsyncAction.ts +++ b/src/scheduler/AsyncAction.ts @@ -74,11 +74,11 @@ export class AsyncAction extends Action { protected recycleAsyncId(scheduler: AsyncScheduler, id: any, delay: number = 0): any { // If this action is rescheduled with the same delay time, don't clear the interval id. - if (delay !== null && this.delay === delay) { + if (delay !== null && this.delay === delay && this.pending === false) { return id; } // Otherwise, if the action's delay time is different from the current delay, - // clear the interval id + // or the action has been rescheduled before it's executed, clear the interval id return root.clearInterval(id) && undefined || undefined; }