Package io.jmix.core.common.event
Class EventHub
java.lang.Object
io.jmix.core.common.event.EventHub
EventHub class implementing the event listening model with concrete event classes.
This class is not thread-safe and should not be accessed concurrently from multiple threads without proper synchronization. * This class is not thread-safe and should not be accessed concurrently from multiple threads without proper synchronization.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription<E> boolean
hasSubscriptions
(Class<E> eventType) Check if there are listeners for event type E.protected Consumer[]
newListenersArray
(int length) <E> void
Fire listeners for event type E.<E> Subscription
Add an event listener for event with type E.void
unsubscribe
(Class<?> eventType) Remove all listeners with the specified event type.<E> boolean
unsubscribe
(Class<E> eventType, Consumer<E> listener) Remove an event listener for event with type E.
-
Field Details
-
EVENTS_MAP_EXPECTED_MAX_SIZE
protected static final int EVENTS_MAP_EXPECTED_MAX_SIZE- See Also:
-
EMPTY_LISTENERS_ARRAY
-
events
-
-
Constructor Details
-
EventHub
public EventHub()
-
-
Method Details
-
subscribe
Add an event listener for event with type E.- Type Parameters:
E
- type of event- Parameters:
eventType
- event classlistener
- listener- Returns:
- subscription object
-
unsubscribe
Remove an event listener for event with type E.- Type Parameters:
E
- type of event- Parameters:
eventType
- event classlistener
- listener- Returns:
- true if listener has been removed
-
unsubscribe
Remove all listeners with the specified event type.- Parameters:
eventType
- event type
-
hasSubscriptions
Check if there are listeners for event type E.- Type Parameters:
E
- type of event- Parameters:
eventType
- event class- Returns:
- true if there are one or more listeners for type E
-
publish
Fire listeners for event type E.- Type Parameters:
E
- type of event- Parameters:
eventType
- event classevent
- event object
-
newListenersArray
-