cachedValue.getPropertyAsValue().addListener()?

If you have a juce::CachedValue and register as a listener by getting the tree’s property as a value…when the cached value changes it never triggers the listener?

cachedValue.getPropertyAsValue().addListener(this);

This is because Value listeners are local to the Value object, not the underlying shared data.
So in your current code, the value which you’ve assigned your listener to is immediately being deleted and your listeners won’t trigger!

You’ll want to have the Value as a member variable in the class that wants to listen to it, then you’ll get listener updates.

1 Like