# boom-js-emitter

> Create custom events on your own. Emit them wherever you want

Latest version **1.1.0** (published 2022-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install boom-js-emitter
pnpm add boom-js-emitter
yarn add boom-js-emitter
bun add boom-js-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 | 1.1.0 |
| Published | 2022-02-09 |
| First published | 2022-02-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Boomtech LLC |
| Maintainers | boomtechllc |
| Keywords | js, events, event-bus, emitter, react |

## Links

- npm: https://www.npmjs.com/package/boom-js-emitter
- Repository: https://github.com/BoomTech-LLC/Boom-JS-Emitter
- Homepage: https://github.com/BoomTech-LLC/Boom-JS-Emitter#readme
- Issues: https://github.com/BoomTech-LLC/Boom-JS-Emitter/issues
- npm.io page: https://npm.io/package/boom-js-emitter

## 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.1.0 (latest) — 2022-02-09
- 1.0.2 — 2022-02-05
- 1.0.1 — 2022-02-04
- 1.0.0 — 2022-02-04

## README

# boom-js-emitter


[![NPM](https://img.shields.io/npm/v/boom-js-emitter.svg)](https://www.npmjs.com/package/boom-js-emitter)
[![github](https://badgen.net/github/stars/BoomTech-LLC/Boom-JS-Emitter)](https://github.com/BoomTech-LLC/Boom-JS-Emitter)
[![github](https://badgen.net/github/issues/BoomTech-LLC/Boom-JS-Emitter)](https://github.com/BoomTech-LLC/Boom-JS-Emitter)
[![NPM](https://badgen.net/npm/dt/boom-js-emitter)](https://www.npmjs.com/package/boom-js-emitter)

<!-- PROJECT LOGO -->
<br />
<p align="center">
  <a href="https://form.boomform.com/">
    <img src="https://cdn.boomte.ch/images/Emiiter.svg" alt="Logo" width="80" height="80">
  </a>

  <h3 align="center">Boom JS Emitter</h3>

  <p align="center">
    The <b>Simplest</b> and the <b>lightest</b> event management tool.
    <br />
    <a href="https://github.com/BoomTech-LLC/Boom-JS-Emitter/issues">Report Bug</a>
    ·
    <a href="https://github.com/BoomTech-LLC/Boom-JS-Emitter/issues">Request Feature</a>
  </p>
</p>




## Getting Started
Hey and welcome. You have started the development with the <b>Simplest</b> and <b>lightest</b> event management tool

You don't need to read huge docs or watch videos for hours to start using this. 

<b> Just read a few sentences below </b>

## 1. Initialization 
Create a new file and name it Emitter<br />
Import <b>Emiiter</b> in new Emiiter File and declare it.<br />
Export the Emitter<br />

<i>Emiiter.js</i>
```jsx
import Emitter from 'boom-js-emitter'

const Emitter = new Emitter()

export default Emitter
```

## 2. Create an event
Import the Emitter you have declared wherever you want.<br />
Create a useEffect and declare an event in it using the subscribe function

```jsx
import React, { useEffect } from 'react'
import Emitter from './../Emitter' // The file you have created


const SomeComponent = () => {

  useEffect(() => {
    Emitter.subscribe("MY_EVENT_NAME", (payload) => {
      console.log("Doing something with my data", payload);
    })
  }, [])
  
  return (
    <>
      The component which I'm proud for
    </>
  )
}
export default SomeComponent
```
`subscribe` creates an event with this name if the event doesn't exist and starts listening to him

## 3. Remove an event
When the component is dead just call the unsubscribe function

```jsx
import React, { useEffect } from 'react'
import Emitter from './../Emitter' // The file you have created


const SomeComponent = () => {

  useEffect(() => {
    Emitter.subscribe("MY_EVENT_NAME", (payload) => {
      console.log("Doing something with my data", payload);
    })
    
    return () => Emitter.unsubscribe("MY_EVENT_NAME")
  }, [])
  
  return (
    <>
      The component which I'm proud for
    </>
  )
}
export default SomeComponent
```

## 4. Trigger the event
I have nothing to say just look at the codes

```jsx
import React from 'react'
import Emitter from './../Emitter' // The file you have craeted


const SomeOtherComponent = () => {
  
  const handleTriggerEvent = () => Emitter.emit("MY_EVENT_NAME", "data 1", "data 2", "and so on ...")
  
  return (
    <div onClick={handleTriggerEvent}>
      Trigger the event
    </div>
  )
}
export default SomeOtherComponent
```

## Yeah as simple as this
This is not a code this is just a<br />
![](https://media.giphy.com/media/12NUbkX6p4xOO4/giphy.gif)

## Made in BoomTech 

<img src="https://cdn.boomte.ch/images/boomtechdeveloper/logo.svg" height="100">

![This is an image](https://cdn.boomte.ch/images/TikoN.png?x=2) | ![This is an image](https://cdn.boomte.ch/images/AraratM.png?x=2) | ![This is an image](https://cdn.boomte.ch/images/SahakS.png?x=2) 
-- | -- | --
Tigran Nazaryan | Ararat Matinyan | Sahak Sahakyan

--- 

[Apache 2.0 License.](https://github.com/BoomTech-LLC/BoomForm-Package/blob/main/LICENSE)

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