Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

emmit

0.0.2 • Public • Published

Emmit

It is a small library for the management of events, this is based on the library mitt, but it is built according to a class.

yarn add -D emmit
npm install -D emmit

Instance

Emmitt operates like any event manager

import Emmit from 'emmit';
 
let events = new Emmit;
 
let jumpUnsubscribe = events.on('jump',(argument)=>{
   // listener event jump
})
 
let anyUnsubscribe = events.on('*',(argument)=>{
   // listener any event
})
 
events.emit('jump',10);
 

as you will notice every time you store an event emmit returns an unsubscribe for the stored event.

Subscribers in the instance

You can define an object that already stores events from the instance of emmit

let events = new Emmit({
   jump : [()=>{
       // listener event jump
   }]
})

Keywords

Install

npm i emmit

DownloadsWeekly Downloads

1

Version

0.0.2

License

ISC

Last publish

Collaborators

  • avatar