Know when all records have updated


I want to know when all the records have updated, my code looks like this at the moment:

promise = Ember.Deferred.promise (deferred) =>
  deferred.resolve() unless @get('deals.length')

  transaction = @get('store').transaction()

  @get('deals').forEach (item) =>
    # do stuff 'didUpdate', =>
      deferred.resolve() if item == @get('deals.lastObject') 'becameInvalid', (result) =>
      deferred.reject() 'becameError', (result)  ->

    transaction.add item



I am doing a moody check in the didUpdate handler above before resolving the promise.

And I am still getting the dreaded error message which I suspect is because records are being side loaded in each update that are ready to be commited and are in the inflight state:

Uncaught Error: Attempted to handle event loadedData on Radium.Deal:ember1536:328 while in state rootState.loaded.updated.uncommitted. Called with undefined

After I resolve the promise from that handler.


Create a promise per item and then Em.RSVP.all(promises).then()