Skip to content

Commit 2352424

Browse files
committed
Re-name scheduledCallback -> scheduledHostCallback
1 parent 4b08d45 commit 2352424

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

packages/scheduler/src/Scheduler.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
534534
}
535535
}
536536

537-
var scheduledCallback = null;
537+
var scheduledHostCallback = null;
538538
var isIdleScheduled = false;
539539
var timeoutTime = -1;
540540

@@ -566,13 +566,18 @@ if (typeof window !== 'undefined' && window._schedMock) {
566566

567567
isIdleScheduled = false;
568568

569+
var prevScheduledCallback = scheduledHostCallback;
570+
var prevTimeoutTime = timeoutTime;
571+
scheduledHostCallback = null;
572+
timeoutTime = -1;
573+
569574
var currentTime = getCurrentTime();
570575

571576
var didTimeout = false;
572577
if (frameDeadline - currentTime <= 0) {
573578
// There's no time left in this idle period. Check if the callback has
574579
// a timeout and whether it's been exceeded.
575-
if (timeoutTime !== -1 && timeoutTime <= currentTime) {
580+
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
576581
// Exceeded the timeout. Invoke the callback even though there's no
577582
// time left.
578583
didTimeout = true;
@@ -584,17 +589,16 @@ if (typeof window !== 'undefined' && window._schedMock) {
584589
requestAnimationFrameWithTimeout(animationTick);
585590
}
586591
// Exit without invoking the callback.
592+
scheduledHostCallback = prevScheduledCallback;
593+
timeoutTime = prevTimeoutTime;
587594
return;
588595
}
589596
}
590597

591-
timeoutTime = -1;
592-
var callback = scheduledCallback;
593-
scheduledCallback = null;
594-
if (callback !== null) {
598+
if (prevScheduledCallback !== null) {
595599
isPerformingIdleWork = true;
596600
try {
597-
callback(didTimeout);
601+
prevScheduledCallback(didTimeout);
598602
} finally {
599603
isPerformingIdleWork = false;
600604
}
@@ -605,7 +609,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
605609
window.addEventListener('message', idleTick, false);
606610

607611
var animationTick = function(rafTime) {
608-
if (scheduledCallback !== null) {
612+
if (scheduledHostCallback !== null) {
609613
// Eagerly schedule the next animation callback at the beginning of the
610614
// frame. If the scheduler queue is not empty at the end of the frame, it
611615
// will continue flushing inside that callback. If the queue *is* empty,
@@ -651,7 +655,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
651655
};
652656

653657
requestHostCallback = function(callback, absoluteTimeout) {
654-
scheduledCallback = callback;
658+
scheduledHostCallback = callback;
655659
timeoutTime = absoluteTimeout;
656660
if (isPerformingIdleWork || absoluteTimeout < 0) {
657661
// Don't wait for the next frame. Continue working ASAP, in a new event.
@@ -667,7 +671,7 @@ if (typeof window !== 'undefined' && window._schedMock) {
667671
};
668672

669673
cancelHostCallback = function() {
670-
scheduledCallback = null;
674+
scheduledHostCallback = null;
671675
isIdleScheduled = false;
672676
timeoutTime = -1;
673677
};

0 commit comments

Comments
 (0)