https://github.com/uppercod/emmit
🙌 It is a small library for the management of events
https://github.com/uppercod/emmit
Last synced: about 1 year ago
JSON representation
🙌 It is a small library for the management of events
- Host: GitHub
- URL: https://github.com/uppercod/emmit
- Owner: UpperCod
- License: gpl-3.0
- Created: 2017-11-27T15:30:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-19T17:57:41.000Z (over 8 years ago)
- Last Synced: 2025-03-17T03:46:14.166Z (over 1 year ago)
- Language: JavaScript
- Size: 27.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Emmit
It is a small library for the management of events, this is based on the library [mitt](https://github.com/developit/mitt), but it is built according to a class.
```bash
yarn add -D emmit
```
```npm
npm install -D emmit
```
## Instance
Emmitt operates like any event manager
```javascript
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
```javascript
let events = new Emmit({
jump : [()=>{
// listener event jump
}]
})
```