# ngx-application-event

> This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.2.

Latest version **0.0.1** (published 2022-04-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install ngx-application-event
pnpm add ngx-application-event
yarn add ngx-application-event
bun add ngx-application-event
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2022-04-13 |
| First published | 2022-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 35 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Maintainers | andantonyan |

## Links

- npm: https://www.npmjs.com/package/ngx-application-event
- Repository: https://github.com/andantonyan/ngx-application-event
- Homepage: https://github.com/andantonyan/ngx-application-event#readme
- Issues: https://github.com/andantonyan/ngx-application-event/issues
- npm.io page: https://npm.io/package/ngx-application-event

## Dependencies (1)

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

## Recent versions

- 0.0.1 (latest) — 2022-04-13

## README

# General Application Event Listener

This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.3.2.

## Usage

```ts
// define custom event types

class UserDeleted {}
```

```ts
// publish event

@Component({...})
export class AppPublisher {
  constructor(private applicationEventService: NgxApplicationEventService) {
  }

  publish(): void {
    this.applicationEventService.publish(new UserDeleted())
  }
}
```

```ts
// listen event in Component

@Component({...})
export class AppListener {
  
  @NgxEventListener
  private on(event: UserDeleted) {
    console.log(`New event: [${event.constructor.name}]`);
  }
}
```


```ts
// listen event in Service

@Service({...})
export class AppListener {
  constructor(private applicationEventService: NgxApplicationEventService) {
  }

  publish(): void {
    this.applicationEventService.publish(new UserDeleted())
  }

  listen(): void {
    this.applicationEventService.listen(UserDeleted).subscribe(console.log)
  }
}
```

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