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

Function scheduleCallbackWithExpiration

code/redux/public/app.js:13830–13853  ·  view source on GitHub ↗
(expirationTime)

Source from the content-addressed store, hash-verified

13828 var timeHeuristicForUnitOfWork = 1;
13829
13830 function scheduleCallbackWithExpiration(expirationTime) {
13831 if (callbackExpirationTime !== NoWork) {
13832 // A callback is already scheduled. Check its expiration time (timeout).
13833 if (expirationTime > callbackExpirationTime) {
13834 // Existing callback has sufficient timeout. Exit.
13835 return;
13836 } else {
13837 // Existing callback has insufficient timeout. Cancel and schedule a
13838 // new one.
13839 cancelDeferredCallback(callbackID);
13840 }
13841 // The request callback timer is already running. Don't start a new one.
13842 } else {
13843 startRequestCallbackTimer();
13844 }
13845
13846 // Compute a timeout for the given expiration time.
13847 var currentMs = now() - originalStartTimeMs;
13848 var expirationMs = expirationTimeToMs(expirationTime);
13849 var timeout = expirationMs - currentMs;
13850
13851 callbackExpirationTime = expirationTime;
13852 callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout });
13853 }
13854
13855 // requestWork is called by the scheduler whenever a root receives an update.
13856 // 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