ixfx
    Preparing search index...

    Class DispatchList<V>

    Maintains a list of listeners to receive data.

    Type parameter is the type of events sent.

    const d = new DispatchList();

    // Eg: add a listener
    d.add(v => {
    // Handle a value
    });

    // Eg. send a value to all listeners
    d.notify(`some value`);

    If event handler returns true, additional handlers are not called.

    Type Parameters

    • V
    Index

    Constructors

    Methods

    • Adds a handler. You get back an id which can be used to remove the handler later.

      Handlers can be added with 'once' flag set to true. This will automatically remove them after the first value is sent to them.

      If handler returns true, subsequent handlers are not invoked.

      Parameters

      • handler: Dispatch<V>
      • options: { once?: boolean } = {}

      Returns string

    • Emit a value to all handlers Returns true if at least one handler reported 'true' as a response. Also returns true

      Parameters

      • value: V

      Returns boolean

    • Remove a handler by its id.

      Parameters

      • id: string

      Returns boolean

      True if handler was removed, false if not found.