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

Function performWork

code/new-context-api/public/app.js:13093–13135  ·  view source on GitHub ↗
(minExpirationTime, isAsync, dl)

Source from the content-addressed store, hash-verified

13091 }
13092
13093 function performWork(minExpirationTime, isAsync, dl) {
13094 deadline = dl;
13095
13096 // Keep working on roots until there's no more work, or until the we reach
13097 // the deadline.
13098 findHighestPriorityRoot();
13099
13100 if (enableUserTimingAPI && deadline !== null) {
13101 var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
13102 stopRequestCallbackTimer(didExpire);
13103 }
13104
13105 if (isAsync) {
13106 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime) && (!deadlineDidExpire || recalculateCurrentTime() >= nextFlushedExpirationTime)) {
13107 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !deadlineDidExpire);
13108 findHighestPriorityRoot();
13109 }
13110 } else {
13111 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) {
13112 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
13113 findHighestPriorityRoot();
13114 }
13115 }
13116
13117 // We're done flushing work. Either we ran out of time in this callback,
13118 // or there's no more work left with sufficient priority.
13119
13120 // If we're inside a callback, set this to false since we just completed it.
13121 if (deadline !== null) {
13122 callbackExpirationTime = NoWork;
13123 callbackID = -1;
13124 }
13125 // If there's work left over, schedule a new callback.
13126 if (nextFlushedExpirationTime !== NoWork) {
13127 scheduleCallbackWithExpiration(nextFlushedExpirationTime);
13128 }
13129
13130 // Clean-up.
13131 deadline = null;
13132 deadlineDidExpire = false;
13133
13134 finishRendering();
13135 }
13136
13137 function flushRoot(root, expirationTime) {
13138 !!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