You may be able to achieve what you’re going for in approach 1 by using CachedValue
to store a type-safe reference to a property inside a ValueTree
. You can store the ValueTree
inside your model class and expose its properties as public CachedValue
members.
This approach does have some trade-offs – for example, if you have one or more ValueTree::Listener
objects listening to the tree that the CachedValue
references, the listener’s valueTreePropertyChanged()
callback may occur before the CachedValue
has been updated (can be worked around by using forceUpdateOfCachedValue()
). There’s some really great information about this approach and some similar alternatives in this thread .