MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / workLoop

Function workLoop

bundle.js:7814–7842  ·  view source on GitHub ↗
(minPriorityLevel,deadline)

Source from the content-addressed store, hash-verified

7812// using one of the normal work loops.
7813break;}// The commit phase produced additional errors. Continue working.
7814}}}}function workLoop(minPriorityLevel,deadline){if(pendingCommit!==null){priorityContext=TaskPriority$1;commitAllWork(pendingCommit);handleCommitPhaseErrors();}else if(nextUnitOfWork===null){resetNextUnitOfWork();}if(nextPriorityLevel===NoWork$2||nextPriorityLevel>minPriorityLevel){return;}// During the render phase, updates should have the same priority at which
7815// we're rendering.
7816priorityContext=nextPriorityLevel;loop:do{if(nextPriorityLevel<=TaskPriority$1){// Flush all synchronous and task work.
7817while(nextUnitOfWork!==null){nextUnitOfWork=performUnitOfWork(nextUnitOfWork);if(nextUnitOfWork===null){!(pendingCommit!==null)?invariant(false,'Should have a pending commit. This error is likely caused by a bug in React. Please file an issue.'):void 0;// We just completed a root. Commit it now.
7818priorityContext=TaskPriority$1;commitAllWork(pendingCommit);priorityContext=nextPriorityLevel;// Clear any errors that were scheduled during the commit phase.
7819handleCommitPhaseErrors();// The priority level may have changed. Check again.
7820if(nextPriorityLevel===NoWork$2||nextPriorityLevel>minPriorityLevel||nextPriorityLevel>TaskPriority$1){// The priority level does not match.
7821break;}}}}else if(deadline!==null){// Flush asynchronous work until the deadline expires.
7822while(nextUnitOfWork!==null&&!deadlineHasExpired){if(deadline.timeRemaining()>timeHeuristicForUnitOfWork){nextUnitOfWork=performUnitOfWork(nextUnitOfWork);// In a deferred work batch, iff nextUnitOfWork returns null, we just
7823// completed a root and a pendingCommit exists. Logically, we could
7824// omit either of the checks in the following condition, but we need
7825// both to satisfy Flow.
7826if(nextUnitOfWork===null){!(pendingCommit!==null)?invariant(false,'Should have a pending commit. This error is likely caused by a bug in React. Please file an issue.'):void 0;// We just completed a root. If we have time, commit it now.
7827// Otherwise, we'll commit it in the next frame.
7828if(deadline.timeRemaining()>timeHeuristicForUnitOfWork){priorityContext=TaskPriority$1;commitAllWork(pendingCommit);priorityContext=nextPriorityLevel;// Clear any errors that were scheduled during the commit phase.
7829handleCommitPhaseErrors();// The priority level may have changed. Check again.
7830if(nextPriorityLevel===NoWork$2||nextPriorityLevel>minPriorityLevel||nextPriorityLevel<HighPriority){// The priority level does not match.
7831break;}}else{deadlineHasExpired=true;}}}else{deadlineHasExpired=true;}}}// There might be work left. Depending on the priority, we should
7832// either perform it now or schedule a callback to perform it later.
7833switch(nextPriorityLevel){case SynchronousPriority$1:case TaskPriority$1:// We have remaining synchronous or task work. Keep performing it,
7834// regardless of whether we're inside a callback.
7835if(nextPriorityLevel<=minPriorityLevel){continue loop;}break loop;case HighPriority:case LowPriority:case OffscreenPriority:// We have remaining async work.
7836if(deadline===null){// We're not inside a callback. Exit and perform the work during
7837// the next callback.
7838break loop;}// We are inside a callback.
7839if(!deadlineHasExpired&&nextPriorityLevel<=minPriorityLevel){// We still have time. Keep working.
7840continue loop;}// We've run out of time. Exit.
7841break loop;case NoWork$2:// No work left. We can exit.
7842break loop;default:invariant(false,'Switch statement should be exhuastive. This error is likely caused by a bug in React. Please file an issue.');}}while(true);}function performWorkCatchBlock(failedWork,boundary,minPriorityLevel,deadline){// We're going to restart the error boundary that captured the error.
7843// Conceptually, we're unwinding the stack. We need to unwind the
7844// context stack, too.
7845unwindContexts(failedWork,boundary);// Restart the error boundary using a forked version of

Callers 1

performWorkCatchBlockFunction · 0.85

Calls 5

commitAllWorkFunction · 0.85
handleCommitPhaseErrorsFunction · 0.85
resetNextUnitOfWorkFunction · 0.85
performUnitOfWorkFunction · 0.85
invariantFunction · 0.70

Tested by

no test coverage detected