Computed model change


#1

I have a computed

compare: Ember.computed("model", function() {
    return this.get('somevalue').getData(this.get('model'));
  })

And service

 getData(content)  {
    let store = this.get('store'),
      promise = getStoreData(store, 'comparetimeframe', this.getParams(content)),
     self = this;
    promise.then(function(data){
      promise.data =  {
        sameTimePercent: data.get('change'),
        pieCompareData : {
          pieData: [{y: 103}, {y: 103}]
        }
      };
    }, function (fail) {
      return fail;
    });
    return promise;
  },

As I understand now the “compare” listens to model change. But I make changes in some array in the model. How to trigger that model has been changed?


#2

You should tell the computed property to specifically listen to any changes to that array.

compare: Ember.computed("model.myArray.[]", function() {
  ...
});