Reputation: 161
Let's say I have something like
property: Em.Object.create(foo: Em.A([]), bar: Em.A([])),
onAnyArrayChange: function(){
//some code
}.observes('WHAT HERE??')
Thing is I don't want to explicitly say
.observes('property.foo.[]', 'property.bar.[]')
I'd love something like
.observes('property.EACH_KEY.[]')
Is there a way to do it?
Upvotes: 0
Views: 158
Reputation: 14943
Yes it is possible with the @each
property.
See: http://emberjs.com/api/classes/Ember.Array.html#property__each
What you need to do is convert your property
from an Ember.Object
into an Ember.ArrayProxy
like this:
property: Em.ArrayProxy.create({
content: [
Em.A([]), // used to be foo
Em.A([]) // used to be bar
]
});
And now you can:
.observes('property.@each.[]')
Upvotes: 1