Created
December 18, 2016 05:49
-
-
Save JoshuaKGoldberg/aad012656d267a940f67df5096ae4d31 to your computer and use it in GitHub Desktop.
NProgress and RequireJS with onResourceLoad
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(); | |
// Tell the user whenever we make progress | |
requirejs.onResourceLoad = () => NProgress.inc()); | |
// Send a network request, and when it's done, hide the bar | |
sendNetworkRequest().then(() => { | |
NProgress.stop(); | |
delete requirejs.onResourceLoad; | |
doOtherWork(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment