Skip to content

Provide method to get EventType of listener #21280

@haenni

Description

@haenni

Describe your motivation

Currently, it is not easily possible to get the number of registered listeners for a certain, exact eventType.
Method com.vaadin.flow.component.ComponentEventBus#getListeners does also include subTypes of the given eventType, which is not always wanted.

For example the call eventBus.getListeners(ItemClickEvent.class) returns a collection that also contains listeners for ItemDoubleClickEvent, since it is a subType of ItemClickEvent. Distinguishing the eventTypes in the returned collection is cumbersome.

Describe the solution you'd like

It would be helpful if there was a method that given a listener, returns its exact eventType. The method signature would be something like public Class<? extends ComponentEvent> getListenerEventType(Object listener). This would allow to iterate over the collection returned by com.vaadin.flow.component.ComponentEventBus#getListeners and check the eventType for every listener.

Describe alternatives you've considered

Using reflection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions