tinyemitter
v1.0.1
Published
Yet another tiny event emitter libary.
Downloads
375
Readme
Tiny Emitter
Yet another tiny event emitter libary.
Install
Use NPM
npm install tinyemitter
Then import it in your project:
// ES6 module
import TinyEmitter from 'tinyemitter'
// Or CommonJS module
const TinyEmitter = require('tinyemitter')
Use with <script>
Download tinyemitter.js from unpkg(min), then:
<script src="path/to/tinyemitter.js"></script>
<script>var e = new TinyEmitter()</script>
Usage
import TinyEmitter from 'tinyemitter'
const e = new TinyEmitter()
function handle (...names) {
console.log(...names)
}
e.on('hello', handle)
e.emit('hello', 'Mike', 'Bob', 'Lucy')
e.off('hello', handle)
That's all.
License
MIT