vendredi 26 février 2016

Trigger observer when new property added to Ember Object

I want to fire an observer that will set a value to a property when another Ember Object has a new property set. So far this is how I've got it:

  relationTotalCountObserver: Ember.observer('item.relationships.attachments', ->
  totalCount = @get 'item.relationships.attachments.totalCount'
  if totalCount isnt undefined
    @set 'relationTotalCount', totalCount
  ).on 'init'

The item does not have any totalCount property before, it will be added eventually using a merge patch and I need to detect that addition somehow.




Aucun commentaire:

Enregistrer un commentaire