Skip to content

Instantly share code, notes, and snippets.

@jmreidy
Created January 20, 2012 16:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save jmreidy/1648047 to your computer and use it in GitHub Desktop.
Save jmreidy/1648047 to your computer and use it in GitHub Desktop.
Backbone.js Loading notification
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