# @jakubforman/ngx-events

> Use custom event broadcast and listen in anywhere in your Angular app.

Latest version **2.0.0** (published 2022-01-04) · 0 weekly downloads

## Install

```sh
npm install @jakubforman/ngx-events
pnpm add @jakubforman/ngx-events
yarn add @jakubforman/ngx-events
bun add @jakubforman/ngx-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 | 2.0.0 |
| Published | 2022-01-04 |
| First published | 2022-01-04 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 64.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Ing. Jakub Josef Forman |
| Maintainers | jakubforman |
| Keywords | ngx, angular, events, broadcast |

## Links

- npm: https://www.npmjs.com/package/@jakubforman/ngx-events
- npm.io page: https://npm.io/package/@jakubforman/ngx-events

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.3.0

## 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) — 2022-01-04
- 1.0.1 — 2022-01-04
- 1.0.0 — 2022-01-04

## README

# NgxEvents

This library was generated for allow you to use broadcast and listeners anywhere in Angular app.

## Install

```bash
# For Angular 13
npm i @jakubforman/ngx-events@2.0.0

# For Angular 12
npm i @jakubforman/ngx-events@1.0.1
```

## How to use it

**Import lib**

```typescript
import {NgxEventsService} from '@jakubforman/ngx-events';
```

**Basic example of use**

```typescript
export class AppComponent {

    constructor(
        private eventsService: NgxEventsService
    ) {

        // Create listener for global use and for remove
        const exampleListener = (data: any | { exampleKey: string }) => {
            console.log(data.exampleKey)
        }

        // Get every brodcast onlistener
        this.eventsService.on('example', exampleListener)
        this.eventsService.on('example', function (data: any | { exampleKey: string }) {
            console.log(data.exampleKey)
        })

        // brodcast in anywhere and send data to every listener with `example`
        this.eventsService.broadcast('example', {exampleKey: "exampleValue"}) // send to 2 listeners
        this.eventsService.broadcast('user-create', {user: {...}}) // send to 0 listeners


        // remove listener
        this.eventsService.off('example', exampleListener)

    }
}
```

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