Skip to content

Instantly share code, notes, and snippets.

@liondancer
Created January 30, 2017 03:41
Show Gist options
  • Save liondancer/fda7e78b154b79c561b038227503a212 to your computer and use it in GitHub Desktop.
Save liondancer/fda7e78b154b79c561b038227503a212 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();
}
}
// call OUTTER loop
whileHeapList();
} else {
// 2nd inner loop
const secondInnerLoop = () => {
log2.asyncCal().then(log => {
if (log) {
// continue iterating current log
secondInnerLoop();
} 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