2.0.1 • Published 9 years ago
nevent v2.0.1
nevent
A tiny event emitter implementation.
Installation
$ npm install --save neventor:
$ yarn add neventIn the browser use browserify or similar.
Usage
First create a new instance of the class.
const NEvent = require('nevent')
const event = new NEvent()Register callbacks:
event.on('an event', val => {
doSomethingWith(val)
})
event.on('another thing', val => {
// etc...
})...and emit events:
event.emit('an event', 42)For simplicity, calling .on() for the same event name will replace the existing handler.