MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / scheduleCallbackWithExpiration

Function scheduleCallbackWithExpiration

code/styling/public/app.js:13579–13602  ·  view source on GitHub ↗
(expirationTime)

Source from the content-addressed store, hash-verified

13577 var timeHeuristicForUnitOfWork = 1;
13578
13579 function scheduleCallbackWithExpiration(expirationTime) {
13580 if (callbackExpirationTime !== NoWork) {
13581 // A callback is already scheduled. Check its expiration time (timeout).
13582 if (expirationTime > callbackExpirationTime) {
13583 // Existing callback has sufficient timeout. Exit.
13584 return;
13585 } else {
13586 // Existing callback has insufficient timeout. Cancel and schedule a
13587 // new one.
13588 cancelDeferredCallback(callbackID);
13589 }
13590 // The request callback timer is already running. Don't start a new one.
13591 } else {
13592 startRequestCallbackTimer();
13593 }
13594
13595 // Compute a timeout for the given expiration time.
13596 var currentMs = now() - originalStartTimeMs;
13597 var expirationMs = expirationTimeToMs(expirationTime);
13598 var timeout = expirationMs - currentMs;
13599
13600 callbackExpirationTime = expirationTime;
13601 callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout });
13602 }
13603
13604 // requestWork is called by the scheduler whenever a root receives an update.
13605 // It's up to the renderer to call renderRoot at some point in the future.

Callers 2

requestWorkFunction · 0.70
performWorkFunction · 0.70

Calls 2

expirationTimeToMsFunction · 0.70

Tested by

no test coverage detected