@jcoreio/typed-event-emitter
v1.3.1
Published
fully type-safe EventEmitter flow declaration
Downloads
1,434
Keywords
Readme
@jcoreio/typed-event-emitter
fully type-safe EventEmitter
flow declaration
Usage
npm install --save @jcoreio/typed-event-emitter
// @flow
import EventEmitter from '@jcoreio/typed-event-emitter'
function createEmitter(): EventEmitter<{
eventA: [string],
eventB: [string, number],
}>
const emitter = createEmitter()
emitter.on('eventA', (foo: string) => {...})
emitter.on('eventB', (foo: string, bar: number) => {...})
emitter.emit('eventA', 'foo')
emitter.emit('eventB', 'foo', 1)