Reputation: 16736
I have a polymer element that has two properties, columWidth
and columnWidthPercentage
.
Now columnWidthPercentage
is a getter like this:
@observable int columnWidth = 100;
@observable double get columnWidthPercentage => 100 * totalWidth / columnWidth;
Is there a way to tell Polymer that columnWidthPercentage
depends on columnWidth
without setting up a columnWidthChanged
function that invoke notifyPropertyChange()
?
Upvotes: 2
Views: 65
Reputation: 76363
You can use @ComputedProperty. Something like the following :
@observable
int columnWidth = 100;
@ComputedProperty('compute(columnWidth)')
double get columnWidthPercentage => readValue(#columnWidthPercentage);
double compute(int width) => 100 * totalWidth / width;
Upvotes: 2