Skip to content

Instantly share code, notes, and snippets.

@jmreidy
Created January 20, 2012 16:08

Revisions

  1. jmreidy created this gist Jan 20, 2012.
    11 changes: 11 additions & 0 deletions app.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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