Skip to content

Instantly share code, notes, and snippets.

@iendjinn
Created July 26, 2018 14:13
Show Gist options
  • Save iendjinn/37aaa0b18d62d9b8dbece71161210ede to your computer and use it in GitHub Desktop.
Save iendjinn/37aaa0b18d62d9b8dbece71161210ede to your computer and use it in GitHub Desktop.
class PromiseEater {
constructor() {
this.currentPromise = null;
}
addToQueue(promise) {
if (this.currentPromise !== null) {
this.currentPromise = this.currentPromise.then(promise);
} else {
this.currentPromise = promise();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment