Emitus
Small Typescript Event Emitter. ⚡️
Some differences with Mitt
Mitt is a pretty cool and very small event emitter library out there, but Emitus differs with it in some aspects such as:
- Emitus has been written and tested entirely in Typescript.
- It uses an array of events instead of a hash.
- It uses a simple
for()
iteration loop withif()
controls, no map functions or coercion. - It doesn't support 'emit-all' or some wildcard feature.
- Its size is just
285bytes
minimized + gzipped (UMD) and844bytes
(CommonJS).
Install
yarn add emitus --dev
npm install emitus --save-dev
UMD file is also available on unpkg:
You can also use the library via window.emitus
.
Usage
e.on'MY_EVENT', myEvente.emit'MY_EVENT', myArgs
API
on
Register a custom event listener.
e.on eventName: string, listener: EmitusListener: void
off
Unregister a custom event listener.
e.off eventName: string, listener?: EmitusListener: void
emit
Calls listener registered for the event named eventName
passing the supplied (optional) arguments.
e.emit eventName: string, args?: any: void
Contributions
Feel free to send some pull request or issues.
License
MIT license
© 2018 José Luis Quintana