mercredi 4 février 2015

Preventing an array from recalculating

I have a simple Computed Property on one of my Ember Data models. It's a question that hasMany answers, and answers have an ordering.


Here's the CP:



// models/question.js
export default DS.Model.extend({
orderedAnswers: function() {
return this.get('answers').sortBy('position');
}.property('answers.@each.position')
});


Elsewhere in my app, I update a property on one of these answers, and this CP gets triggered and recalculated. This causes reflows in my app and causes me to lose app state.


Any ideas why this is happening? The positions aren't changing, I placed a debugger in the CP and verified that.





Aucun commentaire:

Enregistrer un commentaire