https://github.com/hjfitz/mitr
🎩 Tiny event emitter
https://github.com/hjfitz/mitr
emit emitter event event-emitter events
Last synced: 2 months ago
JSON representation
🎩 Tiny event emitter
- Host: GitHub
- URL: https://github.com/hjfitz/mitr
- Owner: hjfitz
- Created: 2019-08-30T07:45:31.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-01T16:22:31.000Z (about 6 years ago)
- Last Synced: 2025-01-30T03:11:22.508Z (9 months ago)
- Topics: emit, emitter, event, event-emitter, events
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/mitr
- Size: 20.5 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🎩 mitr
> Tinier event emitter## Install
```zsh
yarn add mitr
```## Usage
```ts
import Emitter from 'mitr'const mitr = new Emitter()
mitr.on('complete', (data) => {
console.log('callbacks are still cool!')
doSomethingWithData(data);
})fetch('/api/make/coffee').then((data) => {
mitr.emit('complete', data)
})
```## API
### Emitter#
#### on(event: string, callback: Function)
Adds an event listener for event, invoking callback#### off(event: string)
Removes all events of type $event#### emit(event: string, data?: any)
Emit an event to all $event listeners with optional data## Inspiration
[mitt](https://github.com/developit/mitt) by [developit](https://github.com/developit/)