# @hscmap/event-emitter

> EventEmitter for TypeScript

Latest version **0.0.0** (published 2017-08-16) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @hscmap/event-emitter
pnpm add @hscmap/event-emitter
yarn add @hscmap/event-emitter
bun add @hscmap/event-emitter
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.0 |
| Published | 2017-08-16 |
| First published | 2017-08-16 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | michitaro |

## Links

- npm: https://www.npmjs.com/package/@hscmap/event-emitter
- Repository: https://github.com/michitaro/event-emitter
- Issues: https://github.com/michitaro/event-emitter/issues
- npm.io page: https://npm.io/package/@hscmap/event-emitter

## Recent versions

- 0.0.0 (latest) — 2017-08-16

## README

# Event Emitter
EventEmitter for TypeScript

## Install
```sh
npm install --save @hscmap/event-emitter
```

## Example
```typescript
import { EventEmitter } from '@hscmap/event-emitter'


class MyEvent1 {
    constructor(readonly message: string) { }
}

class MyEvent2 {
    constructor(readonly message: string) { }
}


const ee = new EventEmitter()


const off1 = ee.on(MyEvent1, e => {
    throw e
})


ee.on(MyEvent2, e => {
    throw e
})


try {
    ee.emit(new MyEvent2('hello'))
    throw new Error()
}
catch (e) {
    console.assert(e instanceof MyEvent2)
    console.assert(e.message == 'hello')
}


try {
    ee.emit(new MyEvent1('world'))
    throw new Error()
}
catch (e) {
    console.assert(e instanceof MyEvent1)
    console.assert(e.message == 'world')
}


off1()


try {
    ee.emit(new MyEvent1('hello'))
    throw new Error('no handler fired')
}
catch (e) {
    console.assert(e instanceof Error && e.message == 'no handler fired')
}
```

---
_Source: https://npm.io/package/@hscmap/event-emitter · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
