Skip to content

hjfitz/mitr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎩 mitr

Tinier event emitter

Install

yarn add mitr

Usage

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 by developit

Releases

No releases published

Packages

No packages published