You will have to wrap all your nested objects with a class that tells you when something changes. The fact is that if you place an observer only in a first-level object, you will receive notifications only for the properties contained in this object.
For example, imagine you have this object:
var obj = new WrappedObject({ property1: { property1a: "foo", property1b: 20, } })
If you do not wrap the object contained in porperty1, you will receive the โreceiveโ event only for property1 , and only this, because when someone starts obj.property1.property1a = "bar" , the only interaction you will have with obj will be when it requests a reference to the object contained in property1 , and the modification will occur in an unobservable object.
The best approach I can imagine is to repeat all the properties when wrapping the first object and creating a wrapper object recursively for each typeOf(property) == "Object" .
I hope my understanding of your question was correct. Sorry if not! This is my first answer here: $.
source share