light-weight(187B min+gzip) typesafe event emitter
npm install zen-mitt
yarn add zen-mitt
pnpm add zen-mitt
import { mitt } from 'zen-mitt'
const events = mitt<{
foo: [data: number]
arr: [data: string[]]
param: [name: string, age?: number]
}>()
events.on('foo', console.log)
events.emit('foo', 1)
events.on('arr', console.log)
events.emit('arr', ['test'])
events.off('arr')
events.once('param', console.log)
events.emit('param', 'test', 1)
events.off() // clear all listeners
import { Mitt } from 'zen-mitt'
const events = new Mitt()
MIT