Emitter
Simple JavaScript event emitter.
Documentation
Emitter
Class representing simple Emitter.
add
Adds event listener. If listener is identical to existing one, it will be moved to the end of the queue.
Parameters
-
id
string Name of the event to be listened to. -
fn
Function Function to be called when event is fired. -
context
Any Context in which function will be fired.
constructor
Creates simple Emitter.
fire
Fires all event listeners with given ID.
Parameters
-
id
string Name of the event to be fired. -
params
Array=(default []) List of parameters to be passed to functions.
once
Adds event listener that will fire only once.
Parameters
-
id
string Name of the event to be listened to. -
fn
Function Function to be called when event is fired. -
context
Any Context in which function will be fired.
remove
Removes event listener. Does not hing if such listener does not exist.
Parameters
-
id
string Name of the event to be listened to. -
fn
Function Function to be called when event is fired.
Bug reports, feature requests and contact
If you found any bugs, if you have feature requests or any questions, please, either file an issue at GitHub or send me an e-mail at riki@fczbkk.com.
License
Emitter is published under the MIT license.