As far as I know, there is no built-in way to set the value of a property without starting its observer.
You do not have control over how / when / with which argument the observer is called, but you have control over the body of the procedure and, fortunately, you work with the general state ( this ).
So, you can change the behavior of the function based on the flag, which can be accessed from within the function, but does not need to be passed.
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, for example:
_setWithoutCallingObserver: function (value) { this._observerLock = true; this.aValue = value; this._observerLock = false; }
Lukep
source share