Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created January 31, 2017 03:27
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 liondancer/7002f7d7f12892dfc3f3e1e4d01f8a7d to your computer and use it in GitHub Desktop.
Save liondancer/7002f7d7f12892dfc3f3e1e4d01f8a7d to your computer and use it in GitHub Desktop.
const func = () => {
if (condition) {
return asyncCall().then(() => {
if (condition) {
if (condition) {
// continue looping
return func();
} else {
console.log('some logic');
}
} else {
if (condition) {
return func();
} else {
// run a different function that also returns a Promise
return diffFunc();
}
}
});
} else {
// make sure to return a Promise. Is this necessary when wrapped in a .then()?
return Promise.resolve()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment