# @antyper/simple-event-bus

> Simple event bus in rxjs

Latest version **1.0.5** (published 2019-11-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install @antyper/simple-event-bus
pnpm add @antyper/simple-event-bus
yarn add @antyper/simple-event-bus
bun add @antyper/simple-event-bus
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2019-11-05 |
| First published | 2019-11-04 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 47.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Paweł Antyporowicz |
| Maintainers | antyper |
| Keywords | rxjs, event-bus, event-handler, inversify |

## Links

- npm: https://www.npmjs.com/package/@antyper/simple-event-bus
- Repository: https://gitlab.com/pnkp/simple-event-bus-rxjs
- Homepage: https://gitlab.com/pnkp/simple-event-bus-rxjs#readme
- Issues: https://gitlab.com/pnkp/simple-event-bus-rxjs/issues
- npm.io page: https://npm.io/package/@antyper/simple-event-bus

## Dependencies (3)

- [rxjs](https://npm.io/package/rxjs.md) ^6.5.3
- [inversify](https://npm.io/package/inversify.md) ^5.0.1
- [reflect-metadata](https://npm.io/package/reflect-metadata.md) ^0.1.13

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

- 1.0.5 (latest) — 2019-11-05
- 1.0.4 — 2019-11-05
- 1.0.3 — 2019-11-05
- 1.0.2 — 2019-11-04
- 1.0.1 — 2019-11-04
- 1.0.0 — 2019-11-04

## README

## Simple Event Bus

This package help you emit events and handle it in one place. 
Whole project is written in TypeScript and RxJs. 

Library is compatible with Inversify. You can initialize your EventBus in IOC container.

##### Example with Inversify
```typescript
import {EventBus} from "./EventBus";
import {Container} from "inversify";

export const getContainer: () => Container = () => {
    const container: Container = new Container();

    container.bind<TestEventListener>('TestEventListener')
        .to(TestEventListener)
        .inRequestScope();
    
    container.bind<EventBus>('EventBus')
        .toDynamicValue((context) => {
            const eventBus: EventBus = new EventBus();
    
            eventBus.addEvent(TestEvent);
            eventBus.addEventListener(
                TestEvent,
                context.container.get('TestEventListener'),
            );
    
            return eventBus;
        })
        .inRequestScope();
}

const container: Container = getContainer();

const eventBus: EventBus = container.get<EventBus>('EventBus');
// Events are here handled 
eventBus.handle();

const testEvent: TestEvent = new TestEvent();
// Here is your event emitted
eventBus.emitEvent(testEvent);
```

[Simple First Example](https://gitlab.com/pnkp/simple-event-bus-rxjs/tree/master/examples/firstExample)

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