# @raydeck/event-manager

> Base class for managing events

Latest version **1.2.1** (published 2020-11-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install @raydeck/event-manager
pnpm add @raydeck/event-manager
yarn add @raydeck/event-manager
bun add @raydeck/event-manager
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2020-11-05 |
| First published | 2020-07-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ray Deck |
| Maintainers | raydeck |

## Links

- npm: https://www.npmjs.com/package/@raydeck/event-manager
- Repository: https://github.com/rhdeck/event-manager
- Homepage: https://github.com/rhdeck/event-manager#readme
- Issues: https://github.com/rhdeck/event-manager/issues
- npm.io page: https://npm.io/package/@raydeck/event-manager

## Dependencies (1)

- [concat-md](https://npm.io/package/concat-md.md) ^0.3.5

## Recent versions

- 1.2.1 (latest) — 2020-11-05
- 1.2.0 — 2020-11-04
- 1.1.1 — 2020-10-26
- 1.1.0 — 2020-07-26
- 1.0.3 — 2020-07-22
- 1.0.2 — 2020-07-22
- 1.0.1 — 2020-07-22
- 1.0.0 — 2020-07-22

## README

<a name="readmemd"></a>


# @raydeck/event-manager - v1.2.1

## Index

### Variables

* [error](#let-error)
* [listeners](#const-listeners)

### Functions

* [addListener](#addlistener)
* [clear](#clear)
* [getListeners](#getlisteners)
* [remove](#remove)
* [setError](#seterror)
* [trigger](#trigger)

## Variables

### `Let` error

• **error**: *function*

*Defined in [index.ts:65](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L65)*

#### Type declaration:

▸ (`e`: Error): *void | undefined*

**Parameters:**

Name | Type |
------ | ------ |
`e` | Error |

___

### `Const` listeners

• **listeners**: *object*

*Defined in [index.ts:1](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L1)*

#### Type declaration:

* \[ **key**: *string*\]: function[]

## Functions

###  addListener

▸ **addListener**(`key`: string, `f`: function): *function*

*Defined in [index.ts:18](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L18)*

Add a listener for event `key`

**Parameters:**

▪ **key**: *string*

Identifier for event to fire

▪ **f**: *function*

Function to run on trigger

▸ (`options`: object): *Promise‹void›*

**Parameters:**

Name | Type |
------ | ------ |
`options` | object |

**Returns:** *function*

function to remove the listener

▸ (): *void*

___

###  clear

▸ **clear**(`key`: string): *void*

*Defined in [index.ts:50](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L50)*

Remove all event listeners for identifier `key`

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`key` | string | identifier to clear  |

**Returns:** *void*

___

###  getListeners

▸ **getListeners**(`key`: string): *function[]*

*Defined in [index.ts:7](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L7)*

get all listener functions for identifier `key`

**Parameters:**

Name | Type |
------ | ------ |
`key` | string |

**Returns:** *function[]*

___

###  remove

▸ **remove**(`key`: string, `f`: function): *void*

*Defined in [index.ts:59](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L59)*

Remove one event listener
Note that using the return value of `addTrigger` is easier API

**Parameters:**

▪ **key**: *string*

Identifier for event

▪ **f**: *function*

Pointer to function to remove

▸ (`options`: object): *Promise‹void›*

**Parameters:**

Name | Type |
------ | ------ |
`options` | object |

**Returns:** *void*

___

###  setError

▸ **setError**(`newHandler`: function): *void*

*Defined in [index.ts:70](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L70)*

Set the error handler for trigger (default is just to permit the throw)

**Parameters:**

▪ **newHandler**: *function*

▸ (`e`: Error): *void*

**Parameters:**

Name | Type |
------ | ------ |
`e` | Error |

**Returns:** *void*

___

###  trigger

▸ **trigger**(`key`: string, `options`: object): *Promise‹void›*

*Defined in [index.ts:33](https://github.com/rhdeck/event-manager/blob/6fd1256/src/index.ts#L33)*

Trigger the event `key`. Note that if an trigger handler throws, it will stop the show.

**Parameters:**

Name | Type | Description |
------ | ------ | ------ |
`key` | string | identifier for event to trigger |
`options` | object | map of options to pass to the listener functions  |

**Returns:** *Promise‹void›*

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