1.0.3 • Published 9 months ago

@garzj/event-subscriber v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

node-event-subscriber

Proxies subscriptions to an EventEmitter and stores references, allowing for an easy removal.

Features

Installation

npm i event-subscriber

Usage

import { EventEmitter } from 'events';
import { EventSubscriber } from 'event-subscriber';

const myEmitter = new EventEmitter();

myEmitter.on('my-event', () => console.log('Always called!'));
myEmitter.emit('my-event');

const sub = new EventSubscriber(myEmitter);
sub.on('my-event', () => console.log('Temporarily called!'));
myEmitter.emit('my-event');
sub.off();

myEmitter.emit('my-event');

Output

Always called!
Always called!
Temporarily called!
Always called!
1.0.3

9 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago