This package has been deprecated

Author message:

This package is no longer being maintained. You should not use it.

@scant/emitter

0.2.2 • Public • Published

@scant/emitter

Dead simple event emitter.

GitHub license npm

Install

yarn add @scant/emitter

Usage

import createEmitter from '@scant/emitter';

const emitter = createEmitter();

const handleHello = name => console.log(`hello ${name}!`);

// create a listener
emitter.on('hello', handleHello);

// get count of all listeners
emitter.listeners(); // { hello: 1 }

// get count of listeners by name
emitter.listeners('hello'); // { hello: 1 }
emitter.listeners('farewell'); // { farewell: 0 }

// emit the event, with a payload
emitter.emit('hello', 'world');

// remove the listener
emitter.off('hello', handleHello);

// or, remove ALL listeners on the event
// emitter.off('hello');

Dependents (0)

Package Sidebar

Install

npm i @scant/emitter

Weekly Downloads

1

Version

0.2.2

License

MIT

Unpacked Size

7.75 kB

Total Files

7

Last publish

Collaborators

  • w33ble