@vanillajs/emitter
v1.0.0-alpha.7
Published
A tiny, vanillajs event emitter
Downloads
5
Readme
@vanillajs/emitter
A tiny, vanillajs event emitter
Installation
npm install @vanillajs/emitter
Usage
import emitter from '@vanillajs/emitter';
const unsub = emitter.on('ev', sub);
emitter.emit('ev', { a: 10 }); // emit an event
emitter.off('ev', sub); // unsubscribe using off
unsub(); // unsubscribe by calling the method returned by `on`
Legacy UMD Usage
<script src="//unpkg.com/@vanillajs/emitter"></script>
const { emitter } = window.vanillajs;
const unsub = emitter.on('ev', sub);
...