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 |
callback |
function | Will be called when an event meeting the |
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 theevent
passes thefilterList
. Typically called internally when thebus
emits an event.Returns:
undefined -No return value
-
update()
-
Calls EventBusBase#addListener on the bus for all the events that will be detected by the filters.