I’ve looked a bit into the Ember.arrayComputed object because I’d like to create computed arrays that do something like this:
App.SomeController = Ember.ArrayController.extend({
reference: 3,
diffArray: Ember.computed.map('content', 'reference', function(item){
return item - this.get('reference');
}),
})
I’m not sure how I would go about doing something like this, since the dependent keys of arrayComputed seem to have to be arrays.
The other thing that could be done is something like this
App.SomeController = Ember.ArrayController.extend({
reference: 3,
diffArray: Ember.computed.map('content', function(item){
return item - this.get('reference');
}),
referenceChanged: function(){
this.get('diffArray').recomputeAll();
}.observes('reference'),
})
Basically, if an item is added or removed in the array, I only need to calculate the difference for that item, but if the reference changes, then I need to recompute every element.
Any ideas?