@hooked74/single-purpose-emitter
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

Single Purpose Emitter

Build Status npm License Codecov Module Size

Install

npm install @hooked74/single-purpose-emitter

Usage

// initialize
const emitter = new SinglePurposeEmitter();

// attach handlers
const handler1 = () => console.log("handler 1");
emitter.attach(handler1);
emitter.attach((value) => console.log("handler 2", value));

// dispatch
emitter.emit("some value");

// output:
// handler 1
// handler 2 some value

// detach specific handler
emitter.detach(handler1);

// detach all handlers
emitter.detach();

Package Sidebar

Install

npm i @hooked74/single-purpose-emitter

Weekly Downloads

1

Version

1.2.5

License

MIT

Unpacked Size

167 kB

Total Files

14

Last publish

Collaborators

  • hooked174