https://github.com/jcoreio/typed-event-emitter
fully typed EventEmitter flow declaration
https://github.com/jcoreio/typed-event-emitter
skeleton
Last synced: 11 months ago
JSON representation
fully typed EventEmitter flow declaration
- Host: GitHub
- URL: https://github.com/jcoreio/typed-event-emitter
- Owner: jcoreio
- License: mit
- Created: 2018-02-08T20:15:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-01T20:14:11.000Z (over 1 year ago)
- Last Synced: 2024-11-08T11:52:46.507Z (over 1 year ago)
- Topics: skeleton
- Language: TypeScript
- Size: 2.32 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @jcoreio/typed-event-emitter
[](https://circleci.com/gh/jcoreio/typed-event-emitter)
[](https://codecov.io/gh/jcoreio/typed-event-emitter)
[](https://github.com/semantic-release/semantic-release)
[](http://commitizen.github.io/cz-cli/)
[](https://badge.fury.io/js/%40jcoreio%2Ftyped-event-emitter)
fully type-safe `EventEmitter` flow declaration
## Usage
```sh
npm install --save @jcoreio/typed-event-emitter
```
```js
// @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)
```