I am trying to build a class that will trigger events. I will have multiple instances of this class, and I’d like for my testApp to be able to listen to events from all of them.
It seems a little redundant to have to call ofAddListener for each new instance…
Wondering, what is the best approach for this type of problem?
I have tried using static members for the event objects, but the compiler does not like that.
I have figured something out using a bubble-up approach.
I have a container class that is managing the instances, so I register it as a listener for the events, and in its event handler, I trigger another event using the same arguments. My testApp then listens to events from the container class.
PS. I still wonder if there is a way to register a listener that hears all events of a certain type? … besides explicitly registering it for each instance.
a static event should work, which problem were you having with statics?