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

Function performWork

code/event-handlers/public/app.js:13062–13104  ·  view source on GitHub ↗
(minExpirationTime, isAsync, dl)

Source from the content-addressed store, hash-verified

13060 }
13061
13062 function performWork(minExpirationTime, isAsync, dl) {
13063 deadline = dl;
13064
13065 // Keep working on roots until there's no more work, or until the we reach
13066 // the deadline.
13067 findHighestPriorityRoot();
13068
13069 if (enableUserTimingAPI && deadline !== null) {
13070 var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
13071 stopRequestCallbackTimer(didExpire);
13072 }
13073
13074 if (isAsync) {
13075 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime) && (!deadlineDidExpire || recalculateCurrentTime() >= nextFlushedExpirationTime)) {
13076 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !deadlineDidExpire);
13077 findHighestPriorityRoot();
13078 }
13079 } else {
13080 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) {
13081 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
13082 findHighestPriorityRoot();
13083 }
13084 }
13085
13086 // We're done flushing work. Either we ran out of time in this callback,
13087 // or there's no more work left with sufficient priority.
13088
13089 // If we're inside a callback, set this to false since we just completed it.
13090 if (deadline !== null) {
13091 callbackExpirationTime = NoWork;
13092 callbackID = -1;
13093 }
13094 // If there's work left over, schedule a new callback.
13095 if (nextFlushedExpirationTime !== NoWork) {
13096 scheduleCallbackWithExpiration(nextFlushedExpirationTime);
13097 }
13098
13099 // Clean-up.
13100 deadline = null;
13101 deadlineDidExpire = false;
13102
13103 finishRendering();
13104 }
13105
13106 function flushRoot(root, expirationTime) {
13107 !!isRendering ? invariant(false, 'work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method.') : void 0;

Callers 5

performAsyncWorkFunction · 0.70
performSyncWorkFunction · 0.70
interactiveUpdatesFunction · 0.70
flushInteractiveUpdatesFunction · 0.70
flushControlledFunction · 0.70

Calls 6

findHighestPriorityRootFunction · 0.70
recalculateCurrentTimeFunction · 0.70
stopRequestCallbackTimerFunction · 0.70
performWorkOnRootFunction · 0.70
finishRenderingFunction · 0.70

Tested by

no test coverage detected