Necessary Pigeonholing Mechanism
    Wondering what’s next for npm?Check out our public roadmap! »

    evented-ts
    TypeScript icon, indicating that this package has built-in type declarations

    2.0.0 • Public • Published

    Evented

    Fire and listen to events in JavaScript

    npm version

    Install

    npm i evented-ts
    

    Or

    yarn add evented-ts
    

    Import

    import evented from "evented-ts";

    API

    evented.fire(eventName: string, eventArgs?: any): void;

    Fires an event with optional arguments.

    evented.on(eventName: string, listener: (e: Event) => void): () => void;

    Listens to an event. Returns a function that removes the listener when invoked.

    evented.off(eventName: string, listener?: (e: Event) => void): void;

    Removes the given listener for the event name. Otherwise removes all listeners for the event name.

    evented.listensTo(eventName: string): boolean;

    Returns whether listeners exist for a given event name.

    evented.listeners(eventName: string): Array<(event: Event) => void>;

    Returns listeners for a given event name.

    Usage example

    import evented from "evented-ts";
    
    evented.on("hello", (e) => console.log("hello", e.args));
    
    evented.fire("hello", "world");

    Install

    npm i evented-ts

    DownloadsWeekly Downloads

    18

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    4.79 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar