Reputation: 129
when is an observer in polymer 1.x called?
a-component
The a-component has a value property and an observer
properties: {
aValue: {
type: Number,
observer: '_aValueChanged'
}
}
b-component
The b-component has also a value property which can be used for two-way databinding.
properties: {
bValue: {
type: Number,
notify: true
}
}
It uses an a-component and two-way databinding to sync it's value.
<a-component id="a" a-value="{{bValue}}">
What happens if i change the vlaue of bValue
this.bValue = 1;
console.log(this.$.a.aValue);
Is it guaranteed that the observer of the a-compnent is executed before the console.log is executed?
Is it guaranteed that current value (1) is logged?
Thank you
Greets, Meisenmann
Upvotes: 0
Views: 193
Reputation: 137
Yes, the observer is called before console.log()
statement. And also console.log(this.$.a.aValue)
will print "1". If the observer is not called, try using this.set("bValue", 1);
instead of this.bValue = 1;
Upvotes: 1