# jetemit

> events manager

Latest version **7.0.3** (published 2022-05-03) · ISC license · 0 weekly downloads

## Install

```sh
npm install jetemit
pnpm add jetemit
yarn add jetemit
bun add jetemit
```

## 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 | 7.0.3 |
| Published | 2022-05-03 |
| First published | 2018-09-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 45 |
| Author | Behnam Mohammadi |
| Maintainers | itten |
| Keywords | event, events manager |

## Links

- npm: https://www.npmjs.com/package/jetemit
- Repository: https://github.com/behnammodi/jetemit
- Homepage: https://github.com/behnammodi/jetemit#readme
- Issues: https://github.com/behnammodi/jetemit/issues
- npm.io page: https://npm.io/package/jetemit

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

- 7.0.3 (latest) — 2022-05-03
- 7.0.2 — 2021-07-06
- 7.0.1 — 2021-05-25
- 7.0.0 — 2021-01-08
- 6.0.0 — 2020-12-04
- 5.0.0 — 2020-03-12
- 4.0.0 — 2019-08-30
- 3.3.0 — 2019-03-27
- 3.1.1 — 2019-01-23
- 3.1.0 — 2019-01-09
- 3.0.9 — 2018-12-12
- 3.0.8 — 2018-12-06
- 3.0.7 — 2018-12-01
- 3.0.6 — 2018-12-01
- 3.0.5 — 2018-12-01
- … 18 more at https://npm.io/package/jetemit/versions

## README

[![NPM](https://nodei.co/npm/jetemit.png)](https://nodei.co/npm/jetemit/)

<a href="https://www.npmjs.com/package/jetemit">
  <img src="https://img.shields.io/npm/v/jetemit.svg" alt="Version">
</a>

<a href="https://bundlephobia.com/result?p=jetemit">
<img src="https://badgen.net/bundlephobia/minzip/jetemit" alt="Minzipped size">
</a>

<a href="https://www.npmjs.com/package/jetemit">
  <img src="https://badgen.net/npm/dt/jetemit" alt="Downloads">
</a>

<a href="https://www.npmjs.com/package/jetemit">
  <img src="https://img.shields.io/npm/l/jetemit.svg" alt="License">
</a>

An event manager very simple

## Compatibility

| All browser | Backend (Nodejs) | Mobile (React Native) |
| ----------- | ---------------- | --------------------- |
| ✅          | ✅               | ✅                    |

Compatibility with all javascript project

## Install

```npm
npm install jetemit
```

## Import

```javascript
const { on, emit } = require("jetemit");
//or
import { on, emit } from "jetemit";
```

# Use

## Call

```javascript
import { emit } from "jetemit";

/**
 * emit(name, value);
 * name is string
 * value any
 */
emit("TIME", "2018-12-01 12:30");
```

## Listener

```javascript
import { on } from "jetemit";

/**
 * on(name,function)
 * name is string
 */
on("TIME", time => {
  console.log(time);
});
```

```javascript
import { once } from "jetemit";

/**
 * Like on but run one time
 */
once("TIME", time => {
  console.log(time);
});
```

## Unsubscribe listener

```javascript
import { on } from "jetemit";

/**
 * on return unsubscribe function
 */
const unsubscribe = on("TIME", time => {
  console.log(time);
});

unsubscribe();
```

## Using unsubscribeOf function

```javascript
import { unsubscribeOf } from "jetemit";

/**
 * Unsubscribe all subscribed functions for TIME
 */
unsubscribeOf("TIME");
```

## or

```javascript

/**
 * Unsubscribe a Function which subscribed for TIME
 */
unsubscribeOf("TIME", timeFunction);
```

## Refund from all listener

Please see this sample:

```javascript
// file a.js
import { on } from "jetemit";

on("CACHE_STSTEM_HEALTH", () => {
  return { state: "OK", id: "CACHE_SYSTEM_1" };
});
```
```javascript
// file b.jd
import { on } from "jetemit";

on("CACHE_STSTEM_HEALTH", () => {
  return { state: "OK", id: "CACHE_SYSTEM_2" };
});
```
```javascript
// file c.js
import { on, emit } from "jetemit";

const status = emit("CACHE_STSTEM_HEALTH");
console.log(status);
/*
[
  { state: "OK", id: "CACHE_SYSTEM_1" },
  { state: "OK", id: "CACHE_SYSTEM_2" }
]
*/
```

## Donate
BTC: `1NV1sjQnXwuyHgxQ8G5eWprhxsD5A8yN6r`

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