Open bloodcarter opened 7 years ago
This implementation of watching new values isn't recommended, and I just realised it has a bug, probably will be remade in the next version.
You should use like this: http://jsfiddle.net/1jwntatp/
//defining our object no matter which way we want
var ex = {
l1a: "bla bla",
l1b: {
l2a: "lo lo",
l2b: "hey hey",
l2c: null
}
};
watch(ex, function (prop, action, difference, oldvalue){
alert("prop: "+prop+"\n action: "+action+"\n difference: "+JSON.stringify(difference)+"\n old: "+JSON.stringify(oldvalue)+"\n ... and the context: "+JSON.stringify(this));
});
ex.l1b.l2c = "new attr";
The example: "Do you want to know when new attributes change too?" works but somehow not if you have level set o 0, if you set it to eg. 10 it works. (At least in browser)
I tried your example from official docs, but it doesn't catch any changes. Here the full code: