I’m wondering what the JUCE way is to deal with situations like this:
- A user selects an item from the main menu.
- The action connected to that menu item creates a new data item and stores it in a singleton list with synchronized access.
- Several other parts of the UI must react to that event once the item has been created (e.g. to add new components reflecting several different views of that item).
- The newly generated item has an ID that can be used to retrieve the item data from the singleton list wherever it is needed.
Would the “correct” way be to send a notification with the new item’s ID? Or is there a better way where I can pass the (pointer to the) new item’s data directly?
The part of the application that receives the command should be agnostic of the other UI parts, i.e. I am looking for a classic publisher/subscriber model with parameterized topics.
I just found the class ListenerList which can be used to register user-defined types with callbacks - would using that be the prefered way with JUCE?
Thanks for any responses.