From 2352424d581d8e965895a3fad6170b2d559e0ba8 Mon Sep 17 00:00:00 2001 From: Andrew Clark Date: Mon, 8 Oct 2018 17:14:57 -0700 Subject: [PATCH] Re-name scheduledCallback -> scheduledHostCallback --- packages/scheduler/src/Scheduler.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/scheduler/src/Scheduler.js b/packages/scheduler/src/Scheduler.js index 995a465b9fde8..0d586fc2d72a3 100644 --- a/packages/scheduler/src/Scheduler.js +++ b/packages/scheduler/src/Scheduler.js @@ -534,7 +534,7 @@ if (typeof window !== 'undefined' && window._schedMock) { } } - var scheduledCallback = null; + var scheduledHostCallback = null; var isIdleScheduled = false; var timeoutTime = -1; @@ -566,13 +566,18 @@ if (typeof window !== 'undefined' && window._schedMock) { isIdleScheduled = false; + var prevScheduledCallback = scheduledHostCallback; + var prevTimeoutTime = timeoutTime; + scheduledHostCallback = null; + timeoutTime = -1; + var currentTime = getCurrentTime(); var didTimeout = false; if (frameDeadline - currentTime <= 0) { // There's no time left in this idle period. Check if the callback has // a timeout and whether it's been exceeded. - if (timeoutTime !== -1 && timeoutTime <= currentTime) { + if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) { // Exceeded the timeout. Invoke the callback even though there's no // time left. didTimeout = true; @@ -584,17 +589,16 @@ if (typeof window !== 'undefined' && window._schedMock) { requestAnimationFrameWithTimeout(animationTick); } // Exit without invoking the callback. + scheduledHostCallback = prevScheduledCallback; + timeoutTime = prevTimeoutTime; return; } } - timeoutTime = -1; - var callback = scheduledCallback; - scheduledCallback = null; - if (callback !== null) { + if (prevScheduledCallback !== null) { isPerformingIdleWork = true; try { - callback(didTimeout); + prevScheduledCallback(didTimeout); } finally { isPerformingIdleWork = false; } @@ -605,7 +609,7 @@ if (typeof window !== 'undefined' && window._schedMock) { window.addEventListener('message', idleTick, false); var animationTick = function(rafTime) { - if (scheduledCallback !== null) { + if (scheduledHostCallback !== null) { // Eagerly schedule the next animation callback at the beginning of the // frame. If the scheduler queue is not empty at the end of the frame, it // will continue flushing inside that callback. If the queue *is* empty, @@ -651,7 +655,7 @@ if (typeof window !== 'undefined' && window._schedMock) { }; requestHostCallback = function(callback, absoluteTimeout) { - scheduledCallback = callback; + scheduledHostCallback = callback; timeoutTime = absoluteTimeout; if (isPerformingIdleWork || absoluteTimeout < 0) { // Don't wait for the next frame. Continue working ASAP, in a new event. @@ -667,7 +671,7 @@ if (typeof window !== 'undefined' && window._schedMock) { }; cancelHostCallback = function() { - scheduledCallback = null; + scheduledHostCallback = null; isIdleScheduled = false; timeoutTime = -1; };