Last active
October 13, 2017 19:01
-
-
Save pomber/5619519b8fce0174d839419fd44ccf04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ENOUGH_TIME = 1; // milliseconds | |
function performWork(deadline) { | |
workLoop(deadline); | |
if (nextUnitOfWork || updateQueue.length > 0) { | |
requestIdleCallback(performWork); | |
} | |
} | |
function workLoop(deadline) { | |
if (!nextUnitOfWork) { | |
resetNextUnitOfWork(); | |
} | |
while (nextUnitOfWork && deadline.timeRemaining() > ENOUGH_TIME) { | |
nextUnitOfWork = performUnitOfWork(nextUnitOfWork); | |
} | |
if (pendingCommit) { | |
commitAllWork(pendingCommit); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment