EventDispatcher
Implements a list of registered event callbacks.
Constructors
EventDispatcher
Creates instance of `EventDispatcher`.
public void EventDispatcher(
EventCallback<String> onRemoveEntryKey
)
Name | Type | Description |
---|---|---|
onRemoveEntryKey | EventCallback<String> | callback triggered when all events from channel entry have been removed (it can also unsubscribe from the channel) |
Methods
emit
Emits specified event. It should only be called by event loops.
public <T> void emit(
Event<T> event
)
Name | Type | Description |
---|---|---|
event | Event<T> | event data to emit |
register
Registers new event callback.
public boolean register(
String channel,
String type,
Object context,
EventCallback<?> callback
)
Name | Type | Description |
---|---|---|
channel | String | channel of registered event |
type | String | type of registered event |
context | Object | ID of registered callback |
callback | EventCallback<?> | block of code to call when the specified event has been caught |
Type | Description |
---|---|
boolean | `true` if the channel is not already subscribed |
unbind
Removes all callbacks registered by #register(String, String, Object, EventCallback). It's identified by given Context.
public void unbind(
Object context
)
Name | Type | Description |
---|---|---|
context | Object | callback identifier |
unbindAll
Removes all callbacks.
public void unbindAll()