Know which among the dependent keys caused the computed property change

為{幸葍}努か 提交于 2019-12-02 06:20:58

问题


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.


回答1:


Short answer: No, thats not possible.

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




回答2:


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



来源:https://stackoverflow.com/questions/39957886/know-which-among-the-dependent-keys-caused-the-computed-property-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!