Created
May 12, 2016 22:15
-
-
Save humanchimp/ef9621d8589b68d3498a2d30bd71d922 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
let pendingRequests = 0; | |
$(document) | |
.ajaxStart(() => { pendingRequests += 1; }) | |
.ajaxStop(() => { pendingRequests -= 1; }); | |
function andThen(callback) { | |
wait().then(callback); | |
} | |
function wait() { | |
return new RSVP.Promise(resolve => { | |
const watcher = setInterval(() => { | |
if (pendingRequests.length) { return; } | |
clearInterval(watcher); | |
resolve(); | |
}, 30); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment