event-class-es6
event-class-es6 is an ES6 module
providing event communication to ES6 classes.
Installation
npm install --save event-class-es6
Example
{} const event = ; const cb = event; event;
event;"I've been called"event;"I've been called"event;event;event;"I will be called once"event;
API
event
, listener
)
.on(This will register the given listener to the given event, multiple listeners can be added to the same event.
event
, listener
)
.once(Same as .on
but will only calls the listener once for the given event.
event
, [listener=undefined]
)
.off(Removes the given listener from listening to the given event. If listener is undefined, all listeners for the given event will be removed.
event
, [...arguments]
)
.emit(This will call every listeners registered for this given event with the given arguments.