Looking for some help with this code snippet:
<dom-module id="foo-bar">
<template>
<span class$="{{getState()}}">Foo Bar</span>
</template>
<script>
(function() {
class FooBar {
beforeRegister() {
this.is = 'foo-bar';
this.properties = {
data: {
type: Object,
notify: true,
observer: '_updateData'
};
}
getState() {
if (this.data) {
return this.data.val > 0 ? 'positive' : 'negative';
}
}
}
Polymer(FooBar);
})();
</script>
</dom-module>
Currently, the getState
function is only called once, however, the data
property is updated every second. I am wondering if there is a way to automatically update the class$ property when the data
changes.