Event Manager
A simple event manager which have 3 functions :
- on(event : string,listener : function) : attach the listener to the provided event name/id
- fire(event : string, data : any) : Trigger the event and send date with it
- off(event : name, listener : function) : detach the listener from the event given
Exemple
const EventManager = require("@nico78916/event_manager");
function helloWorld(data){
console.log(data);
}
EventManager.on("Event",helloWorld);
EventManager.fire("Event","Hello world!");//Output : Hello world!
EventManager.off("Event",helloWorld);
EventManager.fire("Event","Hello world!");//No output