-
-
Notifications
You must be signed in to change notification settings - Fork 37
Description
Right now, classes and instances can be registered with a bus group, which will register all its applicable methods annotated with @SubscribeEvent to the bus group. This returns a collection of event listeners that can then later be used with BusGroup#unregister to unregister them. The thing is that these event listeners have descriptions given to them by the EventListener interface, which most notably include the event type of the listener. So, if I wanted to unregister a single listener from this collection, I would either have to:
- Use
Collections#singletonorList#ofon the listener and pass it intoBusGroup#register - Manually locate the event type and unregister it from its bus, making sure that the event bus is using the same bus group.
The thing about option 1 is that BusGroup#register will unconditionally run a for loop on this collection, even if it's a singleton. It would be far easier if a sister method exists, which only accepts a single EventListener, that can be used to unregister that one listener. This would remove the need to arbitrarily locate the relevant event bus.