# @totallyinformation/ti-common-event-handler

> A common, shared event handler used across multiple TotallyInformation packages. Implemented as a singleton class.

Latest version **1.0.1** (published 2023-10-24) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @totallyinformation/ti-common-event-handler
pnpm add @totallyinformation/ti-common-event-handler
yarn add @totallyinformation/ti-common-event-handler
bun add @totallyinformation/ti-common-event-handler
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2023-10-24 |
| First published | 2021-09-26 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.0 |
| Dependencies | 1 |
| Unpacked size | 25.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Julian Knight |
| Maintainers | totallyinformation |
| Keywords | events, event-handler |

## Links

- npm: https://www.npmjs.com/package/@totallyinformation/ti-common-event-handler
- Repository: https://github.com/TotallyInformation/ti-common-event-handler
- Homepage: https://github.com/TotallyInformation/ti-common-event-handler#readme
- Issues: https://github.com/TotallyInformation/ti-common-event-handler/issues
- npm.io page: https://npm.io/package/@totallyinformation/ti-common-event-handler

## Dependencies (1)

- [eventemitter2](https://npm.io/package/eventemitter2.md) ^6.4.4

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2023-10-24
- 1.0.0 — 2021-09-26

## README

# ti-common-event-handler

A common, shared event handler used across multiple TotallyInformation packages.
Implemented as a singleton class.

Uses the enhanced EventEmitter2 library for improved performance and support of wildcards

## Installation

```bash
npm install @totallyinformation/ti-common-event-handler
```

## Use as

```js
const tiEvents = require('@totallyinformation/ti-common-event-handler')

const aDataVar = {
    some: 'data'
}

tiEvents.emit('my-event-name', aDataVar)

// NB: Don't use arrow functions if you want to be able to access event name
tiEvents.on('my-event-name', function(data) {
    console.log(`Event ${this.event} triggered: `, data)
})
```

## Event name wildcards

`*` and `**` can be used as wildcards when creating event listeners. `**` will look down all sub-namespaces.

`/` is pre-configured as the namespace separator so as to match the equivalent in MQTT topics.

See the [EventEmitter2](https://github.com/EventEmitter2/EventEmitter2) node for details.

## Current usage

* [node-red-contrib-uibuilder](https://github.com/TotallyInformation/node-red-contrib-uibuilder)
* [node-red-contrib-events](https://github.com/TotallyInformation/node-red-contrib-events)
* [node-red-contrib-drayton-wiser](https://github.com/TotallyInformation/node-red-contrib-drayton-wiser)

## Dependencies

* [EventEmitter2](https://github.com/EventEmitter2/EventEmitter2)

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