Is there a way to call listeners in the order they have been added and not the reversed order that is the default?
I have a singleton object that is the first listener that is added to a ListenerList. Upon callback, it updates itself.
All the other listeners added to the list rely on the state of this singleton for updating their state, but they are added AFTER it and thus they all get their callback BEFORE the singleton.
The result is that they all get called when the singleton has not updated itself yet, because it only does so at the last iteration of the loop in ListenerList::call()
To solve the problem, anything of the following will do:
- an argument in the call method to tell it in which order to walk the list
- the possibility to specify whether one wants the listener to be added at the beginning or the end of the list with an argument to ListenerList::add()
- adding another method ListenerList::addAtBeginning() to do the same...
- adding a general purpose ListenerList::insertAt(index) method