Skip to content

Instantly share code, notes, and snippets.

@pomber
Last active October 13, 2017 18:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pomber/f2a341c6a707d50df6b03bd4bd1a6480 to your computer and use it in GitHub Desktop.
Save pomber/f2a341c6a707d50df6b03bd4bd1a6480 to your computer and use it in GitHub Desktop.
// Fiber tags
const HOST_COMPONENT = "host";
const CLASS_COMPONENT = "class";
const HOST_ROOT = "root";
// Global state
const updateQueue = [];
let nextUnitOfWork = null;
let pendingCommit = null;
function render(elements, containerDom) {
updateQueue.push({
from: HOST_ROOT,
dom: containerDom,
newProps: { children: elements }
});
requestIdleCallback(performWork);
}
function scheduleUpdate(instance, partialState) {
updateQueue.push({
from: CLASS_COMPONENT,
instance: instance,
partialState: partialState
});
requestIdleCallback(performWork);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment