0.0.1 • Published 11 months ago

@7pmlabs/event-bus v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
11 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.1

11 months ago