Last active
July 17, 2019 15:27
-
-
Save NoriSte/86048cc18271c68d1acf7a399abf9e3c to your computer and use it in GitHub Desktop.
Recursive promise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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