-
-
Save mmorrison/3768685 to your computer and use it in GitHub Desktop.
Backbone.js Loading notification
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
activeRequests = [] | |
Backbone._sync = Backbone.sync | |
Backbone.sync = (method, model, options) -> | |
asyncToken = Backbone._sync.apply(this,arguments) | |
asyncToken.then () -> | |
activeRequests = _.without activeRequests, asyncToken | |
if activeRequests.length == 0 then console.log "LOADING COMPLETE" | |
if activeRequests.length == 0 | |
console.log "START LOADING" | |
activeRequests.push asyncToken |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment