知道从属密钥中的哪一个导致计算的属性改变

时间:2016-10-10 12:05:05

标签: node.js ember.js computed-properties

在Ember中,有没有办法让依赖键中的哪一个导致计算属性重新计算?

例如:

myProp: Ember.computed('dep1','dep2','dep3', function(){
    console.log('MyProp was recalculated due to a change in property :' <dep 1,2 or 3(get the value here)>);
    return ...;
}),

请告诉我是否应提供任何其他详细信息。

2 个答案:

答案 0 :(得分:3)

简短回答:不,那是不可能的。

答案很长:您可以保存所有依赖关系键并在重新计算时对它们进行比较。

答案 1 :(得分:0)

如果您在component.js中,则可以检查didUpdateAttributes(options),其中options包含更新属性的旧值和新值。