When you change a property of one component, properties of many different other components can change due to dynamic formulas. Is there any way in Ruby to trace which properties are changing without snapshotting all of them before and after?
Sounds like you need to be changing the attributes of the instance’s “
dynamic attributes” dictionary, and not that of the definition. Normally, the DC engine does this properly, and when it cannot, it will automatically create a unique definition for the “differenced” instance.
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
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.
I generally I’d recommend not to build an extension that relies on Dynamic Components. It was never meant to be incorporated in other extensions and if something changes in the Dynamic Components the other extension’s functionality could break.
This topic was automatically closed after 91 days. New replies are no longer allowed.