# ontime-eventemitter

> EventEmitter to implement mediator pattern

Latest version **1.0.0** (published 2020-04-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install ontime-eventemitter
pnpm add ontime-eventemitter
yarn add ontime-eventemitter
bun add ontime-eventemitter
```

## 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.0.0 |
| Published | 2020-04-18 |
| First published | 2020-04-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 14.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Helen Gotovska |
| Maintainers | ontimelengo |
| Keywords | ontime, eventemitter |

## Links

- npm: https://www.npmjs.com/package/ontime-eventemitter
- Repository: https://github.com/OntimeLengo/ontime-eventemitter
- Homepage: https://github.com/OntimeLengo/ontime-eventemitter#readme
- Issues: https://github.com/OntimeLengo/ontime-eventemitter/issues
- npm.io page: https://npm.io/package/ontime-eventemitter

## 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.0 (latest) — 2020-04-18

## README

<h1>Ontime EventEmitter</h1>

The class is used to implement pattern Mediator. The common idea of the class has been taken from NodeJS native class EventEmitter and class BackboneJS Events.

<h2>How to install</h2>

```bash
npm install ontime-eventemitter
```

<h2>How to use</h2>

```typescript
import { EvenEmitter } from 'ontime-eventemitter';

const emitter: EvenEmitter = new EvenEmitter();

// create callback function
const cb = (name: string): void => console.log('Hello', name);

// subscribe callback
emitter.on('say', cb);

// send event
emitter.emit('say', 'John'); // -> Hello John
emitter.emit('say', 'Helen'); // -> Hello Helen

// unsubscribe callback
emitter.off('say', cb);
```

<h2>Methods</h2>

<h2>on</h2>

on(name: name, callback: Function) - Subscribe callback. The callback will be invoked whenever the event is fired.

<h2>once</h2>

once(name: name, callback: Function) - Just like "on", but causes the callback to fire only once before being removed.

<h2>off</h2>

off(name: name, callback: Function) - Unsubscribe previously callback.

<h2>emit</h2>

emit(name: name, [...args]) - Emit callbacks for the given event. Subsequent arguments to trigger will be passed along to the event callbacks.

<h2>stopListening</h2>

stopListening() - Remove all listeners.

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