Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/smikhalevski/event-bus

🚌 Yet another event bus. There are many like it, but this one is mine.
https://github.com/smikhalevski/event-bus

event-bus pubsub reactive rx

Last synced: 4 days ago
JSON representation

🚌 Yet another event bus. There are many like it, but this one is mine.

Awesome Lists containing this project

README

        

# event-bus [![build](https://github.com/smikhalevski/event-bus/actions/workflows/master.yml/badge.svg?branch=master&event=push)](https://github.com/smikhalevski/event-bus/actions/workflows/master.yml)

Yet another event bus. There are many like it, but this one is mine.

The most primitive implementation of a push-based event bus (pub/sub) that you can find.

```shell
npm install --save-prod @smikhalevski/event-bus
```

```ts
import {EventBus} from '@smikhalevski/event-bus';

interface IFooEvent {
foo: string;
}

const eventBus = new EventBus();

const unsubscribe = eventBus.subscribe((event) => console.log(event.foo));

eventBus.publish({foo: 'abc'}); // Outputs "abc" to console

unsubscribe();
```