Skip to main content
reference

EventDispatcher

Implements a list of registered event callbacks.

Constructors

EventDispatcher

Creates instance of `EventDispatcher`.

public void EventDispatcher(
EventCallback<String> onRemoveEntryKey
)

NameTypeDescription
onRemoveEntryKeyEventCallback<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
)

NameTypeDescription
eventEvent<T>event data to emit

register

Registers new event callback.

public boolean register(
String channel,
String type,
Object context,
EventCallback<?> callback
)

NameTypeDescription
channelStringchannel of registered event
typeStringtype of registered event
contextObjectID of registered callback
callbackEventCallback<?>block of code to call when the specified event has been caught

TypeDescription
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
)

NameTypeDescription
contextObjectcallback identifier

unbindAll

Removes all callbacks.

public void unbindAll()