@jcoreio/typed-event-emitter
TypeScript icon, indicating that this package has built-in type declarations

1.3.1 • Public • Published

@jcoreio/typed-event-emitter

CircleCI Coverage Status semantic-release Commitizen friendly npm version

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)

Readme

Keywords

Package Sidebar

Install

npm i @jcoreio/typed-event-emitter

Weekly Downloads

317

Version

1.3.1

License

MIT

Unpacked Size

7.39 kB

Total Files

7

Last publish

Collaborators

  • gravitate1838
  • avramdodson
  • forrest-keller
  • jrmclaurin
  • jedwards1211
  • eladendorf