Skip to content

Instantly share code, notes, and snippets.

@dcrystalj
Created April 25, 2019 15:09
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 dcrystalj/8ed3d182b3bedab3fd0f0388e7ab5665 to your computer and use it in GitHub Desktop.
Save dcrystalj/8ed3d182b3bedab3fd0f0388e7ab5665 to your computer and use it in GitHub Desktop.
simple promise queue framework
export const PromiseQueue = function() {
let defered = Promise.resolve();
return {
push(fn) {
defered = defered.then(fn, fn);
return this;
}
};
};
export const waitOnQueue = function(fn, time = 100) {
return function() {
return new Promise((resolve, reject) => {
setTimeout(() => {
requestAnimationFrame(() => {
fn();
resolve();
});
}, time);
});
};
};
@dcrystalj
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment