# Know when all records have updated

**URL:** <https://discuss.emberjs.com/t/know-when-all-records-have-updated/1700>\
**Category:** Uncategorized\
**Created:** [July 3, 2013, 4:08pm UTC](https://discuss.emberjs.com/t/know-when-all-records-have-updated/1700 "2013-07-03T16:08:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dagda1](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/dagda1/32/14195_2.png) [@dagda1](https://discuss.emberjs.com/u/dagda1)\
**Post date:** [July 3, 2013, 4:08pm UTC](https://discuss.emberjs.com/t/know-when-all-records-have-updated/1700/1 "2013-07-03T16:08:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kylen](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/kylen/32/14708_2.png) [@kylen](https://discuss.emberjs.com/u/kylen)\
**Post date:** [July 3, 2013, 9:12pm UTC](https://discuss.emberjs.com/t/know-when-all-records-have-updated/1700/2 "2013-07-03T21:12:37Z")

</div>

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