Created
December 18, 2016 05:48
-
-
Save JoshuaKGoldberg/91b0d90f25c7bd07e97d9c9fdaa57798 to your computer and use it in GitHub Desktop.
NProgress and RequireJS with an interval
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
// Start showing a progress bar | |
NProgress.start(); | |
// Make the user think we're continuously making progress | |
const timer = setInterval(() => NProgress.inc(), 100); | |
// Send a network request, and when it's done, hide the bar | |
sendNetworkRequest().then(() => { | |
clearInterval(timer); | |
NProgress.stop(); | |
doOtherWork(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment