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

Function scheduleCallbackWithExpiration

code/third-party/public/app.js:12812–12835  ·  view source on GitHub ↗
(expirationTime)

Source from the content-addressed store, hash-verified

12810 var timeHeuristicForUnitOfWork = 1;
12811
12812 function scheduleCallbackWithExpiration(expirationTime) {
12813 if (callbackExpirationTime !== NoWork) {
12814 // A callback is already scheduled. Check its expiration time (timeout).
12815 if (expirationTime > callbackExpirationTime) {
12816 // Existing callback has sufficient timeout. Exit.
12817 return;
12818 } else {
12819 // Existing callback has insufficient timeout. Cancel and schedule a
12820 // new one.
12821 cancelDeferredCallback(callbackID);
12822 }
12823 // The request callback timer is already running. Don't start a new one.
12824 } else {
12825 startRequestCallbackTimer();
12826 }
12827
12828 // Compute a timeout for the given expiration time.
12829 var currentMs = now() - originalStartTimeMs;
12830 var expirationMs = expirationTimeToMs(expirationTime);
12831 var timeout = expirationMs - currentMs;
12832
12833 callbackExpirationTime = expirationTime;
12834 callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout });
12835 }
12836
12837 // requestWork is called by the scheduler whenever a root receives an update.
12838 // 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