Created
January 30, 2017 07:34
-
-
Save liondancer/82f482f2931a08b2ee1fa83e17fd54e4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const outerFunc = () => { | |
var i = 0 | |
return new Promise(resolve => { | |
if (i < 3) { | |
i++ | |
const innerFunc = () => { | |
return new Promise(resolve => { | |
return log.asyncCall().then(log => { | |
if (log) { | |
// some logic | |
} else { | |
resolve() | |
} | |
}).then(() => { | |
// continue iterating innerFunc() | |
return innerFunc(); | |
}); | |
}) | |
}; | |
// first iteration innerFunc() | |
return innerFunc().then(() => { | |
// once innerFunc() is complete, reiterate outerFunc() | |
return outerFunc(); | |
}); | |
} else { | |
resolve(); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment