- Type Parameters:
T- - the event type
public interface EventDispatcher<T>
Manages
EventSubscribers for a single event type.-
Method Summary
Modifier and TypeMethodDescriptionbooleandispatch(T event, EventContext context) Dispatches the specified event to all subscribers contained within this dispatcher.booleanbooleanregister(EventSubscriber<T> subscriber) Registers anEventSubscriber.booleanunregister(EventSubscriber<T> subscriber) Unregisters anEventSubscriber.
-
Method Details
-
register
Registers anEventSubscriber.- Parameters:
subscriber- - subscriber to register- Returns:
trueif this dispatcher did not already contain the specified subscriber
-
unregister
Unregisters anEventSubscriber.- Parameters:
subscriber- - subscriber to unregister- Returns:
trueif this dispatcher contained the specified subscriber
-
hasSubscribers
boolean hasSubscribers()- Returns:
trueif this dispatcher contains no subscribers
-
dispatch
Dispatches the specified event to all subscribers contained within this dispatcher.- Parameters:
event- - event to dispatchcontext- - event context- Returns:
trueif subscribers were removed as a result of the dispatch
-