Griffon 1.2.0

griffon.core
[Java] Interface EventRouter


public interface EventRouter

An event handling helper.

Listeners may be of type

With the exception of Maps and Closures, the naming convention for an eventHandler is "on" + eventName, Maps and Closures require handlers to be named as eventName only.

Some examples of eventHandler names are: onStartupStart, onMyCoolEvent. Event names must follow the camelCase naming convention.

Authors:
Andres Almiray


Method Summary
void addEventListener(Object listener)

Adds an event listener.

void addEventListener(Map listener)

Adds a Map containing event listeners.

void addEventListener(String eventName, Closure listener)

Adds a Closure as an event listener.

void addEventListener(String eventName, RunnableWithArgs listener)

Adds a Runnable as an event listener.

boolean isEnabled()

Returns the current enabled state.

void publish(String eventName)

Publishes an event with optional arguments.

void publish(String eventName, List params)

Publishes an event with optional arguments.

void publishAsync(String eventName)

Publishes an event with optional arguments.

void publishAsync(String eventName, List params)

Publishes an event with optional arguments.

void publishOutsideUI(String eventName)

Publishes an event with optional arguments.

void publishOutsideUI(String eventName, List params)

Publishes an event with optional arguments.

void removeEventListener(Object listener)

Removes an event listener.

void removeEventListener(Map listener)

Removes a Map containing event listeners.

void removeEventListener(String eventName, Closure listener)

Removes a Closure as an event listener.

void removeEventListener(String eventName, RunnableWithArgs listener)

Removes a Runnable as an event listener.

void setEnabled(boolean enabled)

Sets the enabled state of this router.

 

Method Detail

addEventListener

public void addEventListener(Object listener)
Adds an event listener.

A listener may be a

With the exception of Maps, the naming convention for an eventHandler is "on" + eventName, Maps require handlers to be named as eventName only.

Some examples of eventHandler names are: onStartupStart, onMyCoolEvent. Event names must follow the camelCase naming convention.

Parameters:
listener - an event listener of type Script, Map or Object


addEventListener

public void addEventListener(Map listener)
Adds a Map containing event listeners.

An event listener may be a

Maps require handlers to be named as eventName only.

Some examples of eventHandler names are: StartupStart, MyCoolEvent. Event names must follow the camelCase naming convention.

Parameters:
listener - an event listener of type Script, Map or Object


addEventListener

public void addEventListener(String eventName, Closure listener)
Adds a Closure as an event listener.

Event names must follow the camelCase naming convention.

Parameters:
eventName - the name of the event
listener - the event listener


addEventListener

public void addEventListener(String eventName, RunnableWithArgs listener)
Adds a Runnable as an event listener.

Event names must follow the camelCase naming convention.

Parameters:
eventName - the name of the event
listener - the event listener


isEnabled

public boolean isEnabled()
Returns the current enabled state.
Returns:
true if the router is enabled; false otherwise.


publish

public void publish(String eventName)
Publishes an event with optional arguments.

Event listeners will be notified in the same thread that originated the event.
Parameters:
eventName - the name of the event


publish

public void publish(String eventName, List params)
Publishes an event with optional arguments.

Event listeners will be notified in the same thread that originated the event.
Parameters:
eventName - the name of the event
params - the event's arguments


publishAsync

public void publishAsync(String eventName)
Publishes an event with optional arguments.

Event listeners are guaranteed to be notified in a different thread than the publisher's, always.
Parameters:
eventName - the name of the event


publishAsync

public void publishAsync(String eventName, List params)
Publishes an event with optional arguments.

Event listeners are guaranteed to be notified in a different thread than the publisher's, always.
Parameters:
eventName - the name of the event
params - the event's arguments


publishOutsideUI

public void publishOutsideUI(String eventName)
Publishes an event with optional arguments.

Event listeners are guaranteed to be notified outside of the UI thread always.
Parameters:
eventName - the name of the event


publishOutsideUI

public void publishOutsideUI(String eventName, List params)
Publishes an event with optional arguments.

Event listeners are guaranteed to be notified outside of the UI thread always.
Parameters:
eventName - the name of the event
params - the event's arguments


removeEventListener

public void removeEventListener(Object listener)
Removes an event listener.

A listener may be a

With the exception of Maps, the naming convention for an eventHandler is "on" + eventName, Maps require handlers to be named as eventName only.

Some examples of eventHandler names are: onStartupStart, onMyCoolEvent. Event names must follow the camelCase naming convention.

Parameters:
listener - an event listener of type Script, Map or Object


removeEventListener

public void removeEventListener(Map listener)
Removes a Map containing event listeners.

An event listener may be a

Maps require handlers to be named as eventName only.

Some examples of eventHandler names are: StartupStart, MyCoolEvent. Event names must follow the camelCase naming convention.

Parameters:
listener - an event listener of type Script, Map or Object


removeEventListener

public void removeEventListener(String eventName, Closure listener)
Removes a Closure as an event listener.

Event names must follow the camelCase naming convention.

Parameters:
eventName - the name of the event
listener - the event listener


removeEventListener

public void removeEventListener(String eventName, RunnableWithArgs listener)
Removes a Runnable as an event listener.

Event names must follow the camelCase naming convention.

Parameters:
eventName - the name of the event
listener - the event listener


setEnabled

public void setEnabled(boolean enabled)
Sets the enabled state of this router.

A disabled router will simply discard all events that are sent to it, in other words listeners will never be notified. Discarded events cannot be recovered, even if the router is enabled at a later point in time.
Parameters:
enabled - the value for the enabled state


 

Groovy Documentation