Suppose we have a model like this:
App.Somemodel = DS.Model.extend({
A:DS.attr('number'),
B:DS.attr('number'),
CP: function(){return this.get('A') + this.get('B');}.property('A','B')
})
My question is this :When is CP going to be re calculated ? - Right after A changed (before record.save() ) - After the record is saved ? - At the moment when this record is retrieved from store again ?
My second question is : Is the behavior because of the computed property itself ?
I am now struggling with some issues: when updating 1000+ records at the same time ,The efficiency get terrible .
I was trying to understand :Is it a good idea to define computed-property in the model ?
CP will be calculated every time the A or B is set (unless they both manage to get set in one run loop). The computed property is bound to both A and B.
That is why is it preferable to put the computed property in the controller. Let the controller decorate the model. The computed property will then only be calculated when the controller is active - when it is actually required.