Like the title says. Is there a way to modify a observed valued without triggering the observer callback in Polymer?
For example
Polymer({
is: 'my-component',
properties: {
aValue: {
type: Number,
value: 0,
observer: '_valueChanged',
notify: true
},
ref: {
type: Object,
computed: '_computeRef(channel, channelNumber)'
}
},
_computeRef: function(channel, channelNumber) {
var ref = new Firebase("/*link*/");
ref.on("child_changed", function(data) {
this.aValue.setWithoutCallingObserver(data.val());
}.bind(this));
return ref;
},
_valueChanged: function() {
var message = { aValue: this.aValue };
if (this.ref) {
this.ref.set(message);
}
}
});
This would be useful because now I am experiencing lag in the following scenario:
aValue
in a third party appUpdate: The issue is not firebase related. I believe the solution is in getting control over how updates are applied to observed values in Polymer. Partly because changes to the values in the firebase store can be made by 3th party (not necessarily web) applications too.
[MobX] Since strict-mode is enabled, changing (observed) observable values without using an action is not allowed. Tried to modify: [email protected] Everything works as expected. How can I fix this issue? Show activity on this post.
For example, if you changing two values inside some handler without action then your component might re-render twice instead of once. makeAutoObservable wraps all methods automatically but you still need to handle async methods and Promises manually. Thanks for contributing an answer to Stack Overflow!
The ONLY thing that accesses the volume is the slider, period. So it would go like this: This basically means you cannot do a Model View Controller architecture using the new UI system without adding quite ugly code (I am currently writing said ugly code).
To my knowledge, there is not built in way to set a property value without triggering it's observer.
You don't have control over how/when/with what arguments the observer is called, but you do have control over the procedure body and, luckily, you are working with a shared state (this
).
So, you can modify the behavior of the function based on a flag that can be accessed from within the function, but doesn't have to be passed in.
For example:
_valueChanged: function (new_val, old_val) {
if (this._observerLock) { return; }
var message = { aValue: this.aValue };
if (this.ref) {
this.ref.set(message);
}
}
},
...
Then, you can implement the _setWithoutCallingObserver()
method like:
_setWithoutCallingObserver: function (value) {
this._observerLock = true;
this.aValue = value;
this._observerLock = false;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With