Skip to content

Instantly share code, notes, and snippets.

@webpapaya
Created November 16, 2016 09:26
Show Gist options
  • Save webpapaya/3343d3bf990317cd0a1fa9776b0a8c5b to your computer and use it in GitHub Desktop.
Save webpapaya/3343d3bf990317cd0a1fa9776b0a8c5b to your computer and use it in GitHub Desktop.
const queue = new PromiseQueue();
const anotherTask = () => { /* do something fancy */ };
const errorTask = () => { /* do something fancy */ };
const myApiCall1 = () => Promise.resolve()
.then(() => { queue.push(anotherTask) })
.catch(() => { queue.push(errorTask) })
queue.resolve().then((results) => {
console.log(results);
}).catch((error) => {
console.log(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment