const emitter = reim({message: 'abc'})
emitter.on('test', () => {
// … react to 'test' event
});
emitter.once('test', (...args) => {
// … react to first 'test' event (invoked only once!)
});
emitter.emit('test', arg1, arg2/*…args*/); // Two above listeners invoked
emitter.emit('test', arg1, arg2/*…args*/); // Only first listener invoked
emitter.off('test', listener); // Removed first listener
emitter.emit('test', arg1, arg2/*…args*/); // No listeners invoked
emitter.subscribe(() => emitter.emit('update-message'), state => state.message) // Emit on state change