mercredi 25 février 2015

Ember properties with multiple dependencies dont update as expected

I have following issue concerning understanding ember properties:


If i have a propertyA:



propertyA: function() {
return this.get("propertyB.someObject.someValue");
}.property("propertyB")


and a propertyB:



propertyB: function() {
return this.get("propertyY.someObject");
}.property("propertyX", "propertyY", "propertyZ")


And i have a binding for propertyA in some template like:



{{propertyA}}


Then in 90% of the cases in my code it happens that propertyA does not get updated properly when i set i.e. propertyX.


If i understand it correctly, then propertyB should become dirty as soon as one of the dependent properties (like propertyX) changes. This should automatically make propertyA dirty and thus update it automatically since it has a binding.


What happens in my code is, that propertyA remains the old cached value even when i called it in the console, but when i call propertyB it revaluates and returns the updated code, since it was dirty.


The question is, why does propertyA not automatically become dirty when propertyB does? Is it because propertyB has no binding in a template? I thought it is not necessary if propertyA has the dependence.


I also figured out that this problem does not occur when propertyB just depends on propertyX, so the multi-dependency must somehow mess things up.


Sorry for this quite complicated explanation but i tried to abstract my actual code as simple as possible.





Aucun commentaire:

Enregistrer un commentaire