Have ideas to improve npm?Join in the discussion! »

    @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();
     

    Install

    npm i @hooked74/single-purpose-emitter

    DownloadsWeekly Downloads

    22

    Version

    1.2.5

    License

    MIT

    Unpacked Size

    167 kB

    Total Files

    14

    Last publish

    Collaborators

    • avatar