README
ES6 Events
A simple event emitter and listener built in ES6.
Methods
eventhub.on
Init listener on string.
eventhub.on('string', handler);
eventhub.onAll
Init listener on all strings.
eventhub.on('string', handler);
eventhub.once
Fire event only once, then remove the event.
eventhub.once('string', handler);
eventhub.emit
Fire event on string with arguments.
eventhub.emit('string', ...args);
Fire event on string without arguments.
eventhub.emit('string');
eventhub.remove
Remove event from the eventhub list with the same string and handler.
eventhub.remove('event', handler);
Remove event from the eventhub list with the same string.
eventhub.remove('string');
Usage
import Eventhub from 'eventhub';
const eventhub = new Eventhub();
eventhub.on('text-change', text => {
console.log('Text changed to', text);
});
eventhub.emit('text-change', 'New Text');
or
import Eventhub from 'eventhub';
const eventhub = new Eventhub()
.on('text-change', text => {
console.log('Text changed to', text);
})
.emit('text-change', 'New Text');
License
MIT