# minsky-event-dispatcher

> Event dispatcher

Latest version **1.0.0** (published 2020-09-28) · ISC license · 0 weekly downloads

## Install

```sh
npm install minsky-event-dispatcher
pnpm add minsky-event-dispatcher
yarn add minsky-event-dispatcher
bun add minsky-event-dispatcher
```

## 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.0 |
| Published | 2020-09-28 |
| First published | 2020-09-28 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Minsky |
| Maintainers | minsky |
| Keywords | event |

## Links

- npm: https://www.npmjs.com/package/minsky-event-dispatcher
- Repository: https://bitbucket.org/Minsky_WebAgency/eventdispatcher
- Homepage: https://bitbucket.org/Minsky_WebAgency/eventdispatcher#readme
- npm.io page: https://npm.io/package/minsky-event-dispatcher

## Dependencies (1)

- [minsky-base](https://npm.io/package/minsky-base.md) ^1.0.0

## 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-09-28

## README

# EventDispatcher

**Provide classes with Event management logic**

Event management is a handy piece of logic to allow classes to communicate with each other without having to provide their logic on their own.
Contains two classes 'Event dispatcher' & 'Event'

Classes need to extend from 'vent Dispatcher', events are dispatched will be instances of 'Event'.

‌

**Class type:** `Manager`

## Dependencies

* Base - 1.0.0

---

## Getting started

EventDispatcher can be used both standalone or as base for a class to extend from

```javascript
// standalone
const dispatcher = new EventDispatcher()


// extend
export default class Dispatcher extends EventDispatcher {
	// ...
}
```

### Constructor Parameters

… Base constructor parameters

---

## Interface

### Options

#### silent

Type: `Boolean`
Default: `false`

Sets instance to silent on creation so it won’t dispatch events when dispatch is called.

… Base constructor options

### Properties

#### listeners

Type: `Object`
Default: `{}`

Collection of all the binded listeners.

#### silent

Type: `Boolean`
Default: `false`

Toggles silent state of instance.

… Base properties

### Methods

#### on

Parameters: `event [, data] [, callback]`
Return: `self`

Binds a listener to an event

#### once

Parameters: `event [, data] [, callback]`
Return: `self`

Binds a listener to an event and will remove the binding once the event has been dispatched.

#### off

Parameters: `event [, callback] [, process]`
Return: `self`

Removes certain binding of certain event. Will remove all bindings if callback isn’t provided.

#### dispatch

Parameters: `event [, data] [, process]`
Return: `self`

Dispatch a given event so all the listeners would be called.

Extra data can be provided to the Event data using the data parameter. It will merge the original data with the new.

Process is a method that can will be run right before every listener of the given event is called.

#### destroy

Parameters: `none`
Return: `self`

Clears all bindings and destroys the instance. No need for Off\(\) to be called before destruction as it will happened automatically.

… Base methods

---

## To Do

* None

---

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