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

Function performWork

code/controlled-uncontrolled/public/app.js:13056–13098  ·  view source on GitHub ↗
(minExpirationTime, isAsync, dl)

Source from the content-addressed store, hash-verified

13054 }
13055
13056 function performWork(minExpirationTime, isAsync, dl) {
13057 deadline = dl;
13058
13059 // Keep working on roots until there's no more work, or until the we reach
13060 // the deadline.
13061 findHighestPriorityRoot();
13062
13063 if (enableUserTimingAPI && deadline !== null) {
13064 var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
13065 stopRequestCallbackTimer(didExpire);
13066 }
13067
13068 if (isAsync) {
13069 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime) && (!deadlineDidExpire || recalculateCurrentTime() >= nextFlushedExpirationTime)) {
13070 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !deadlineDidExpire);
13071 findHighestPriorityRoot();
13072 }
13073 } else {
13074 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) {
13075 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
13076 findHighestPriorityRoot();
13077 }
13078 }
13079
13080 // We're done flushing work. Either we ran out of time in this callback,
13081 // or there's no more work left with sufficient priority.
13082
13083 // If we're inside a callback, set this to false since we just completed it.
13084 if (deadline !== null) {
13085 callbackExpirationTime = NoWork;
13086 callbackID = -1;
13087 }
13088 // If there's work left over, schedule a new callback.
13089 if (nextFlushedExpirationTime !== NoWork) {
13090 scheduleCallbackWithExpiration(nextFlushedExpirationTime);
13091 }
13092
13093 // Clean-up.
13094 deadline = null;
13095 deadlineDidExpire = false;
13096
13097 finishRendering();
13098 }
13099
13100 function flushRoot(root, expirationTime) {
13101 !!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