Skip to content

Event Listeners created with BusGroup#register cannot easily be unregistered individually #74

@Jonathing

Description

@Jonathing

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:

  1. Use Collections#singleton or List#of on the listener and pass it into BusGroup#register
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions