Skip to content

Instantly share code, notes, and snippets.

@nuxodin
Last active July 1, 2021 13:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuxodin/e1a052ac4d351fa82dce9f9e7071bba1 to your computer and use it in GitHub Desktop.
Save nuxodin/e1a052ac4d351fa82dce9f9e7071bba1 to your computer and use it in GitHub Desktop.
writeStack = [];
write = function(callback){
if (!writeStack.length) requestAnimationFrame(handleWriteStack);
writeStack.push(callback);
}
handleWriteStack = function(){
while (writeStack.length) writeStack.pop()();
}
readStack = [];
read = function(callback){
//if (!readStack.length) requestPostAnimationFrame(handleReadStack);
if (!readStack.length) setTimeout(handleReadStack);
readStack.push(callback);
}
handleReadStack = function(){
while (readStack.length) readStack.pop()();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment