List side-effects of a component attribute change

Attribute changes cause the EntityObserver#onChangeEntity callback to fire for any Entity sublcass object the observer is attached to.

You could also attach such an observer to the “dynamic_attributes” dictionary object, of a specific entity as well rather than having it fire for every change of the owner object. (This works because dictionaries are themselves a subclass of Entity.)

But, yes you’d still need to snapshot them, or create a copy of the entire dictionary to start with, and then compare the attributes within the callback to find the one that changed.

It is difficult to change the copy (within the callback) because doing so will cause the same callback to fire which is a recursive call, and … vicious loop … and crash! (You’d need to keep some flag variable to know when you’re not inside the first callback call, etc., so as to not create a endless loop.)


It so would be very nice to have a dedicated dictionary observer class with an onAttributeChangeReady() callback (as well as others to react to dictionary changes, additions and deletions.)

Currently, such as class does not exist.

1 Like