EventListener(bus, filterList, callback)

Listens for events on the specified EventBusBase, applying the specified EventFilters before calling the specified callback.

new EventListener(bus, filterList, callback)

Creates an event listener for the specified bus, calling the callback function for any events that meet pass the filterList

Parameters:
Name Type Description
bus EventBusBase

The event bus to listen on

filterList EventFilter | Array.<EventFilter> | null

A list of events to filter on. If null all events on the bus will call callback or filters may be added later using the EventListener#addFilter method.

callback function

Will be called when an event meeting the filterList criteria is received. Callback has a single argument of an EventBase event.

Members

static listenAllList

The Array of callback functions registered with listenAll

Methods

static clearListenAll()

Clears all callback functions registered with listenAll

static listenAll(fn)

Registers a callback function to be called on every event

Parameters:
Name Type Description
fn function

The callback function to be called on every event. It will be passed the event that triggered it.

addFilter(filter)

Adds a filter to the EventListener. If the filter has a priority it will be added in priority order; otherwise, it will be added to the end of the list.

Parameters:
Name Type Description
filter EventFilter

The new filter to add.

applyFilter(event) → {undefined}

Triggers the callback specified in the constructor if the event passes the filterList. Typically called internally when the bus emits an event.

Parameters:
Name Type Description
event EventBase

An event derived from the EventBase class

Returns:
undefined -

No return value

update()

Calls EventBusBase#addListener on the bus for all the events that will be detected by the filters.