Skip to content

Instantly share code, notes, and snippets.

@NoriSte
Last active July 17, 2019 15:27
Show Gist options
  • Save NoriSte/86048cc18271c68d1acf7a399abf9e3c to your computer and use it in GitHub Desktop.
Save NoriSte/86048cc18271c68d1acf7a399abf9e3c to your computer and use it in GitHub Desktop.
Recursive promise
let recursivePromise = (partial = []) => {
return new Promise((resolve, reject) => {
const result = /* your logic */;
resolve(result);
//reject();
}).then((result) => {
partial.push(result);
if(/* when to continue recursively */) {
return recursivePromise(partial);
}
return partial;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment