Skip to content

Instantly share code, notes, and snippets.

@mmorrison
Forked from jmreidy/app.coffee
Created March 7, 2012 22:37
Show Gist options
  • Save mmorrison/1996798 to your computer and use it in GitHub Desktop.
Save mmorrison/1996798 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