Package Exports
- @hooked74/single-purpose-emitter
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@hooked74/single-purpose-emitter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Single Purpose Emitter
Install
npm install @hooked74/single-purpose-emitterUsage
// 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();