Skip to content

Instantly share code, notes, and snippets.

@meelash
Created June 14, 2013 21:14
Show Gist options
  • Save meelash/5785328 to your computer and use it in GitHub Desktop.
Save meelash/5785328 to your computer and use it in GitHub Desktop.
Workaround of issues with chaining/nesting under @each in computed properties/ bound observers: https://github.com/emberjs/ember.js/issues/541
I wanted to do something like this:
App.ApplicationController = Ember.Controller.extend
selectedAccounts: (->
accounts = []
(@get 'currentUser.entities').forEach (entity)->
accounts.pushObjects entity.get('accounts').filterProperty 'selected'
accounts
).property('currentUser.entities.@each.accounts.@each.selected')
To workaround, I did this:
App.ApplicationController = Ember.Controller.extend
selectedAccounts: (->
accounts = []
(@get 'currentUser.entities').forEach (entity)->
accounts.pushObjects entity.get('selectedAccounts')
accounts
).property('currentUser.entities.@each.selectedAccounts')
App.Entity = DS.Model.extend
selectedAccounts: (->
(@get 'accounts').filterProperty 'selected'
).property 'accounts.@each.selected'
@joliss
Copy link

joliss commented Aug 29, 2013

See also http://emberjs.com/blog/2013/08/29/ember-1-0-rc8.html , section Array Computed on how to get these things working without ruining performance (hopefully).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment