You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
observe(object, listener) do not catch modifications to existing props of object done with set. It only catches new property added. See jsfiddle: https://jsfiddle.net/4j6b3srp/
consta=mobx.extendObservable({},{},{},{deep: false})mobx.observe(a,console.log)/*logs { type: "add", object: {…}, name: "prop1", newValue: "new prop"}as expected*/mobx.set(a,"prop1","new prop")/*expected to log { type: "update", object: {…}, oldValue: "new prop", name: "prop1", newValue: "changed with set()"}but log do not happens*/mobx.set(a,"prop1","changed with set()")/*logs { type: "update", object: {…}, oldValue: "changed with set()", name: "prop1", newValue: "changed with setter"}as expected*/a.prop1="changed with setter"
I think intercept is also affected
The text was updated successfully, but these errors were encountered:
The first time when a new property is set, defineObservableProperty is called and will notify all listeners bound to obj, but subsequent calls to set get out the existingObservable which is an observable value with its own listeners.
Possible solution might be to set the new value through the parent observable object? In that case notification will go through for both the object and the value. Could make a PR if this sounds okay.
observe(object, listener)
do not catch modifications to existing props of object done withset
. It only catches new property added. See jsfiddle: https://jsfiddle.net/4j6b3srp/I think
intercept
is also affectedThe text was updated successfully, but these errors were encountered: