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

Function scheduleCallbackWithExpiration

code/composition/public/app.js:13717–13740  ·  view source on GitHub ↗
(expirationTime)

Source from the content-addressed store, hash-verified

13715 var timeHeuristicForUnitOfWork = 1;
13716
13717 function scheduleCallbackWithExpiration(expirationTime) {
13718 if (callbackExpirationTime !== NoWork) {
13719 // A callback is already scheduled. Check its expiration time (timeout).
13720 if (expirationTime > callbackExpirationTime) {
13721 // Existing callback has sufficient timeout. Exit.
13722 return;
13723 } else {
13724 // Existing callback has insufficient timeout. Cancel and schedule a
13725 // new one.
13726 cancelDeferredCallback(callbackID);
13727 }
13728 // The request callback timer is already running. Don't start a new one.
13729 } else {
13730 startRequestCallbackTimer();
13731 }
13732
13733 // Compute a timeout for the given expiration time.
13734 var currentMs = now() - originalStartTimeMs;
13735 var expirationMs = expirationTimeToMs(expirationTime);
13736 var timeout = expirationMs - currentMs;
13737
13738 callbackExpirationTime = expirationTime;
13739 callbackID = scheduleDeferredCallback(performAsyncWork, { timeout: timeout });
13740 }
13741
13742 // requestWork is called by the scheduler whenever a root receives an update.
13743 // 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