A tiny library with asynchronous Promise-based implementation of events dispatching and handling.
This library works in Node and in Browser environments (UMD) and is optimized for very small size (under 1000 bytes raw, under 500 bytes gz).
npm install async-eventer
Node.js:
var Eventer = require('async-eventer')
var instance = Eventer();
// Do stuff
Browser:
requirejs(['async-eventer'], function (Eventer) {
var instance = Eventer();
// Do stuff
})
Register event handler.
Register one-time event handler (just on()
+ off()
under the hood).
Unregister event handler.
Dispatch an event with arbitrary number of parameters.
tests/index.ls
contains usage examples.
Feel free to create issues and send pull requests (for big changes create an issue first and link it from the PR), they are highly appreciated!
When reading LiveScript code make sure to configure 1 tab to be 4 spaces (GitHub uses 8 by default), otherwise code might be hard to read.
Free Public License 1.0.0 / Zero Clause BSD License