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

Function performWork

code/one-direction-data-flow/public/app.js:13605–13647  ·  view source on GitHub ↗
(minExpirationTime, isAsync, dl)

Source from the content-addressed store, hash-verified

13603 }
13604
13605 function performWork(minExpirationTime, isAsync, dl) {
13606 deadline = dl;
13607
13608 // Keep working on roots until there's no more work, or until the we reach
13609 // the deadline.
13610 findHighestPriorityRoot();
13611
13612 if (enableUserTimingAPI && deadline !== null) {
13613 var didExpire = nextFlushedExpirationTime < recalculateCurrentTime();
13614 stopRequestCallbackTimer(didExpire);
13615 }
13616
13617 if (isAsync) {
13618 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime) && (!deadlineDidExpire || recalculateCurrentTime() >= nextFlushedExpirationTime)) {
13619 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !deadlineDidExpire);
13620 findHighestPriorityRoot();
13621 }
13622 } else {
13623 while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && (minExpirationTime === NoWork || minExpirationTime >= nextFlushedExpirationTime)) {
13624 performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false);
13625 findHighestPriorityRoot();
13626 }
13627 }
13628
13629 // We're done flushing work. Either we ran out of time in this callback,
13630 // or there's no more work left with sufficient priority.
13631
13632 // If we're inside a callback, set this to false since we just completed it.
13633 if (deadline !== null) {
13634 callbackExpirationTime = NoWork;
13635 callbackID = -1;
13636 }
13637 // If there's work left over, schedule a new callback.
13638 if (nextFlushedExpirationTime !== NoWork) {
13639 scheduleCallbackWithExpiration(nextFlushedExpirationTime);
13640 }
13641
13642 // Clean-up.
13643 deadline = null;
13644 deadlineDidExpire = false;
13645
13646 finishRendering();
13647 }
13648
13649 function flushRoot(root, expirationTime) {
13650 !!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