# yelljs

> Yelljs Yelling-like communication in your app

Latest version **0.4.0** (published 2023-03-04) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.4.0 |
| Published | 2023-03-04 |
| First published | 2018-04-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | alejandro alvarez |
| Maintainers | alejoreact |

## Links

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

## Recent versions

- 0.4.0 (latest) — 2023-03-04
- 0.3.0 — 2020-06-27
- 0.2.2 — 2019-03-14
- 0.2.0 — 2019-03-14
- 0.0.3 — 2018-04-20
- 0.0.2 — 2018-04-09
- 0.0.1 — 2018-04-09

## README

<p align="center">
  <h1 align="center"> Yelljs </h1>
</p>
<p align="center">
  Yelling-like communication in your app
</p>

<hr/>

<h3> Download & Installation </h3>

```shell
yarn add yelljs
```

<h3> Usage </h3>

```javascript
import { yell, hear, mute } from "yelljs";

// We have a drink behavior
const drink = (liquid) => console.log("drinking fresh " + liquid);

// every time a 'drinking' event fires, we want our drink function to execute
// for subscribing we use 'hear'
hear("drinking", drink);

// now anywhere on our app at anytime we can call the yell function with our 'drinking' speaker
yell("drinking", "water");
//> drinking fresh water

// all the arguments passed to yell will be passed to the listener function
const drink = (liquid1, liquid2) => {
  console.log("drinking " + liquid + " with " + liquid2);
};
yell("drinking", "hot chocolate", "milk");
//> drinking fresh hot chocolate with milk

// to stop our drink function to execute further we use 'mute'
// we have to pass as arguments the speaker and the function we want to stop,
// since multiple function can be attached to the same speaker
mute("drinking", drink);

// you can also get a 'silence' function that will mute the exact function you passed with hear
const stopDrinking = hear("drinking", drink);
yell("drinking"); // will execute the drink function
stopDrinkingWine();
yell("drinking"); // will not execute the drink function

// promises/async support is also available via yellAsync
// yellAsync will return a promise that will resolve when all the listeners have resolved
const delayedDrink = async () => {
  await new Promise((resolve) => setTimeout(resolve, 1000));
  console.log("delayed gulp gulp");
};
hear("getWater", delayedDrink);
yellAsync("getWater");
//> delayed gulp gulp

// you can also create a yelljs instance to have more control over who can hear/yell on the system

import Yell from "yelljs";
const myYell = new Yell();

const drink = () => console.log("gulp gulp");

const stopDrinking = myYell.hear("getWater", drink);
myYell.yell("getWater");
//> gulp gulp
stopDrinking();
```

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