Created
June 10, 2018 22:01
-
-
Save MostlyFocusedMike/2f44e904f5b679fb36855c1486e30811 to your computer and use it in GitHub Desktop.
This file contains 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
function grabber(resource, fakeStatus) { | |
return new Promise((resolve, reject) => { | |
window.setTimeout(() => { | |
if (fakeStatus === 200) { | |
resolve(`load ${resource}`) | |
} else { | |
reject("Error") | |
} | |
}, 3000); | |
}); | |
} | |
grabber("article1", 200) | |
.then((result) => { | |
console.log(result); | |
return grabber("comments", 200) | |
}) | |
.then((result) => { | |
console.log(result) | |
console.log("All loaded!") | |
}) | |
.catch((result) => console.log(result, "there was an issue")) | |
console.log("The page assets we don't want to reload"); | |
// LOG: The page assets we don't want to reload | |
** 3 seconds ** | |
// LOG: load article1 | |
** 3 seconds ** | |
// LOG: load comments | |
// LOG19 All loaded! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment