Know which among the dependent keys caused the com

2019-02-26 12:21发布

In Ember, is there a way to get which among the dependent keys caused a computed property to recalculate?

eg:

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 ...;
}),

Kindly let me know if I should provide any additional details.

2条回答
祖国的老花朵
2楼-- · 2019-02-26 12:25

Short answer: No, thats not possible.

Long answer: You could save away all dependency keys and compare them on recalculation.

查看更多
爷的心禁止访问
3楼-- · 2019-02-26 12:32

If you are in a component.js you can check didUpdateAttributes(options) where options contains the old and new values of updated attributes.

查看更多
登录 后发表回答