$ cnpm install nanoevents
Simple and tiny event emitter library for JavaScript.
on method returns unbind function. You don’t need to save
callback to variable for removeListener.emit and on 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.
Read full docs here.
Copyright 2013 - present © cnpmjs.org | Home |