nanoevents
v9.1.0
Published
Simple and tiny (107 bytes) event emitter library
Downloads
530,150
Maintainers
Readme
Nano Events
Simple and tiny event emitter library for JavaScript.
- Only 108 bytes (minified and brotlied). It uses Size Limit to control size.
- The
on
method returnsunbind
function. You don’t need to save callback to variable forremoveListener
. - TypeScript and ES modules support.
- No aliases, just
emit
andon
methods. No Node.js EventEmitter compatibility.
import { createNanoEvents } from 'nanoevents'
const emitter = createNanoEvents()
const unbind = emitter.on('tick', volume => {
summary += volume
})
emitter.emit('tick', 2)
summary //=> 2
unbind()
emitter.emit('tick', 2)
summary //=> 2
Made at Evil Martians, product consulting for developer tools.
Docs
Read full docs here.