Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created January 30, 2017 03:39
Show Gist options
  • Save liondancer/aa250df299228a18d01ef709803a97c7 to your computer and use it in GitHub Desktop.
Save liondancer/aa250df299228a18d01ef709803a97c7 to your computer and use it in GitHub Desktop.
.then(() => {
var i = 0;
const whileHeapList = () => {
i++;
if (i < 5) {
// artifically delayed call
log.asyncCall().then(log => {
if (log) {
// first inner loop
const firstInnerLoop = () => {
if (j < 5) {
j++;
// continue iterating loop
firstInnerLoop();
}
}
} else {
// 2nd inner loop
const secondInnerLoop = () => {
log2.asyncCal().then(log => {
if (log) {
// continue iterating current log
asyncMSG();
} else {
// break out of current loop and iterate OUTTER loop
whileHeapList();
}
});
}
}
})
// continue iterating CURRENT loop --> whileHeapList
whileHeapList();
}
};
return new Promise(whileHeapList);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment