0.0.11 • Published 6 months ago

7pmlabs-event-bus v0.0.11

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

7pmlabs-event-bus

Lightweight native event bus in Typescipt.

Getting started

npm i 7pmlabs-event-bus

Usage

import { EventBus } from '7pmlabs-event-bus';

Event bus instance is signleton but you can give it a different name if you want to have more than one instance:

const eventBus = EventBus.getInstance();

Listen to a specific event:

eventBus.on('MY-CUSTOM-EVENT', (e) => {});

Listen only one time to a specific event:

eventBus.once('MY-CUSTOM-EVENT', (e) => {});

Emit an event:

eventBus.emit('MY-CUSTOM-EVENT', 'Hello world!');

Remove listener for a specific event:

eventBus.off('MY-CUSTOM-EVENT', (e) => {});
0.0.10

6 months ago

0.0.11

6 months ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago