# js-simple-events

> Yet another simple event management system

Latest version **1.2.3** (published 2019-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install js-simple-events
pnpm add js-simple-events
yarn add js-simple-events
bun add js-simple-events
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.3 |
| Published | 2019-10-16 |
| First published | 2018-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | kaskar2008 |
| Maintainers | kaskar2008, raiondesu |
| Keywords | Simple, Events, JS, TS, Light, Management |

## Links

- npm: https://www.npmjs.com/package/js-simple-events
- Repository: https://github.com/kaskar2008/js-simple-events
- Homepage: https://github.com/kaskar2008/js-simple-events#readme
- Issues: https://github.com/kaskar2008/js-simple-events/issues
- npm.io page: https://npm.io/package/js-simple-events

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.2.3 (latest) — 2019-10-16
- 1.2.2 — 2019-10-16
- 1.2.1 — 2019-10-16
- 1.2.0 — 2019-10-16
- 1.1.1 — 2019-09-30
- 1.0.10 — 2019-09-30
- 1.0.9 — 2019-09-30
- 1.0.8 — 2019-09-30
- 1.0.7 — 2018-03-25
- 1.0.6 — 2018-03-25
- 1.0.5 — 2018-03-25
- 1.0.4 — 2018-03-25
- 1.0.3 — 2018-03-25
- 1.0.2 — 2018-03-25
- 1.0.1 — 2018-03-25
- … 1 more at https://npm.io/package/js-simple-events/versions

## README

# js-simple-events
> Yet another simple event management system

`npm i -S js-simple-events`

## About

This is just a simple class that helps to manage events in a simple way without dependencies. It also supports TypeScript!

And it's really light - <1kb in size!

## Methods

Method   | Params            | Description
-------- | ----------------- | ----------------------------------------------------------------
`emit`   | `event, payload`  | Emit the event with the given payload.
`fire`   | `event, payload`  | _Alias for `emit`_
`on`     | `event, callback` | Listen for the event with the given callback.
`listen` | `event, callback` | _Alias for `on`_
`once`   | `event, callback` | Listen for the event once, after handling - remove the listener.
`off`    | `event, callback` | Remove event listener(s) for the event.
`remove` | `event, callback` | _Alias for `off`_

## Examples

```js
// Import and initialize
import EventManager from 'js-simple-events'

const eventManager = new EventManager();


// Define handlers
const eventHandler = (payload) => console.log('Yay, events work!', payload);

eventManager.on('test', eventHandler);
eventManager.once('test', () => console.log('This will be called just once!'));

// Emit events
eventManager.emit('test', 'Hello!');
// -> Yay, events work! Hello!
// -> This will be called just once!

eventManager.emit('test', 'Hello!');
// -> Yay, events work! Hello!
// (The 'once' handler isn't fired)
```

## Plugins

### [For Vue.js](https://github.com/kaskar2008/vue-simple-events)

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