Package io.jmix.flowui.kit.event
Class EventBus
java.lang.Object
io.jmix.flowui.kit.event.EventBus
- All Implemented Interfaces:
Serializable
An event bus for any object.
Handles adding and removing event listeners, and firing events of type any type.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<E extends EventObject>
com.vaadin.flow.shared.RegistrationaddListener
(Class<E> eventType, Consumer<E> listener) Adds a listener for the given event type.<E extends EventObject>
voidfireEvent
(E event) Dispatches the event to all listeners registered for the event type.<E extends EventObject>
booleanhasListener
(Class<E> eventType) Checks if there is at least one listener registered for the given event type.protected Consumer[]
newListenersArray
(int length) <E extends EventObject>
voidremoveListener
(Class<E> eventType) Removes all listeners for the given event type.<E extends EventObject>
voidremoveListener
(Class<E> eventType, Consumer<E> listener) Removes the given listener for the given event type.
-
Field Details
-
EVENTS_MAP_EXPECTED_MAX_SIZE
protected static final int EVENTS_MAP_EXPECTED_MAX_SIZE- See Also:
-
EMPTY_LISTENERS_ARRAY
-
events
-
-
Constructor Details
-
EventBus
public EventBus()
-
-
Method Details
-
addListener
public <E extends EventObject> com.vaadin.flow.shared.Registration addListener(Class<E> eventType, Consumer<E> listener) Adds a listener for the given event type.- Type Parameters:
E
- the event type- Parameters:
eventType
- the event type for which to call the listenerlistener
- the listener to call when the event occurs- Returns:
- an object which can be used to remove the event listener
-
hasListener
Checks if there is at least one listener registered for the given event type.- Type Parameters:
E
- the event type- Parameters:
eventType
- the component event type- Returns:
true
if at least one listener is registered,false
otherwise
-
fireEvent
Dispatches the event to all listeners registered for the event type.- Parameters:
event
- the event to fire
-
removeListener
Removes the given listener for the given event type.- Type Parameters:
E
- the event type- Parameters:
eventType
- the component event typelistener
- the listener to remove
-
removeListener
Removes all listeners for the given event type.- Type Parameters:
E
- the event type- Parameters:
eventType
- the component event type
-
newListenersArray
-