# state-event-emitter

> ES6 event emitter to communicate state between application components

Latest version **2.0.0** (published 2018-05-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install state-event-emitter
pnpm add state-event-emitter
yarn add state-event-emitter
bun add state-event-emitter
```

## 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 | 2.0.0 |
| Published | 2018-05-02 |
| First published | 2018-04-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | josephchapman |
| Keywords | Event Emitter, State Management, Application Communication |

## Links

- npm: https://www.npmjs.com/package/state-event-emitter
- Repository: https://github.com/joechapan/state-event-emitter
- Homepage: https://github.com/joechapan/state-event-emitter#readme
- Issues: https://github.com/joechapan/state-event-emitter/issues
- npm.io page: https://npm.io/package/state-event-emitter

## Dependencies (2)

- [babel-core](https://npm.io/package/babel-core.md) ^6.26.0
- [babel-jest](https://npm.io/package/babel-jest.md) ^22.4.3

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

- 2.0.0 (latest) — 2018-05-02
- 1.0.0 — 2018-04-23

## README

# state-event-emitter
ES6 event emitter to communicate state between application components

## Use case
When each component of an application needs a portion of the application state and the components should be decoupled, this module provides a means to share the state of the application between its components in a pub/sub fashion.

## API
`on` - register an event and listener or just a listener that is registered to `*`.
Supports namespaces i.e.
```js
  emitter.on('a.b.c', listener);

  // listener will execute for each of the following
  emitter.emit('a');
  emitter.emit('a.b');
  emitter.emit('a.b.c');
```

`off` - unregister all listeners of an event or just a single listener of an event

`load` - load the application state in the emitter

`emit` - trigger the listener of an event with the state or subset the state, i.e.
```js
  emitter.on('my-event', listener);
  emitter.emit('my-event:b', {a, 1, b: {c: 2}});

  // listener will be executed with {b: {c: 2}}
```

## Scripts
```bash
$ npm t
```

```bash
$ npm run lint
```

Contributions and comments welcome.

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