new LokiEventEmitter()
LokiEventEmitter is a minimalist version of EventEmitter. It enables any constructor that inherits EventEmitter to emit events and trigger listeners that have been added to the event through the on(event, callback) method
Members
addListener
Alias of LokiEventEmitter.prototype.on addListener(eventName, listener) - adds a listener to the queue of callbacks associated to an event
asyncListeners
Properties:
Name | Type | Description |
---|---|---|
asyncListeners |
boolean | boolean determines whether or not the callbacks associated with each event should happen in an async fashion or not Default is false, which means events are synchronous |
events
Properties:
Name | Type | Description |
---|---|---|
events |
hashmap | a hashmap, with each property being an array of callbacks |
Methods
emit(eventName, dataopt)
emit(eventName, data) - emits a particular event with the option of passing optional parameters which are going to be processed by the callback provided signatures match (i.e. if passing emit(event, arg0, arg1) the listener should take two parameters)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
eventName |
string | the name of the event |
|
data |
object |
<optional> |
optional object passed with the event |
on(eventName, listener) → {int}
on(eventName, listener) - adds a listener to the queue of callbacks associated to an event
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | Array.<string> | the name(s) of the event(s) to listen to |
listener |
function | callback function of listener to attach |
Returns:
the index of the callback in the array of listeners for a particular event
- Type
- int
removeListener(eventName, listener)
removeListener() - removes the listener at position 'index' from the event 'eventName'
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string | Array.<string> | the name(s) of the event(s) which the listener is attached to |
listener |
function | the listener callback function to remove from emitter |