Skip to content

Instantly share code, notes, and snippets.

@plagi
Forked from jmreidy/app.coffee
Created February 6, 2012 21:51
Show Gist options
  • Save plagi/1755161 to your computer and use it in GitHub Desktop.
Save plagi/1755161 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