@nico78916/event_manager

1.0.1 • Public • Published

Event Manager

A simple event manager which have 3 functions :

  1. on(event : string,listener : function) : attach the listener to the provided event name/id
  2. fire(event : string, data : any) : Trigger the event and send date with it
  3. 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

Package Sidebar

Install

npm i @nico78916/event_manager

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

3.05 kB

Total Files

4

Last publish

Collaborators

  • nico78916