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
item.one 'didUpdate', =>
deferred.resolve() if item == @get('deals.lastObject')
item.one 'becameInvalid', (result) =>
deferred.reject()
item.one 'becameError', (result) ->
deferred.reject()
transaction.add item
transaction.commit()
promise
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.