Is there a way to order the calls to
valueTreeChildRemoved? I have several classes that listens to the Edit and would like the calls occur in a defined sequence. In order words, a have the calls to the listeners indexed in some way.
No sorry, there’s no way to determine this order.
If you need all changes to have happened before you take an action you should trigger an async update (as ValueTree::Listener callbacks happen synchronously they will have finished by the time the async callback happens).
IIRC value trees use a
juce::SortedSet to store pointers to their listeners which means listeners are called in the order they’re arranged in memory. So you can garantee (?) the order if all the listeners are stack allocated. However that’s very much an implementation detail and so shouldn’t be relied upon.
That’s what I mean. The order is “unspecified” so can’t be relied upon and could change at any point in JUCE or Tracktion Engine (e.g. if we add more internal listeners).
Also it could change if you add your own listeners or do things in a different order.
Basically just don’t rely on it.
Thanks for the replies.
It’s not crucial for what I’m doing but would be something nice to have.
I can’t imagine it would be all that hard to allow an exec index when adding listeners to the Edit.
Anyway, food for thought.
Several new features for ValueTree may appear as nice additions, but they have the potential to break the fundamental concept of ValueTrees. ValueTree is built on the principles of Model-View-Controller (MVC), emphasizing decoupling. The idea is to ensure that ValueTree listeners remain unaware of other ValueTree listeners, as well as unaware about the specifics of how or when other ValueTree listeners (of which again they have no knowledge), receive callbacks.