Skip to content

Instantly share code, notes, and snippets.

@liondancer

liondancer/tests.js

Created Jan 30, 2017
Embed
What would you like to do?
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