map.apps Bundle APIs 4.20.2
    Preparing search index...

    Interface Evented<Events>

    Base class which provides default on/emit functions to child classes.

    Events are specified by providing a type or interface as a type parameter. The type parameter should list the supported event names and the event value type (or void if there is no value).

    interface MyEvents {
    numberChanged: number; // event handlers will receive a number value
    print: void; // event handlers will receive no value
    }

    class MyClass extends Evented<MyEvents> {
    // ...
    }

    const object = new MyClass();
    object.on("numberChanged", (value) => {
    // value is a number
    });
    interface Evented<Events> {
        emit<Name extends string>(
            eventName: Name,
            ...value: Params<Events[Name]>,
        ): void;
    }

    Type Parameters

    • Events

    Hierarchy (View Summary)

    Index

    Methods

    Methods

    • Emits an event. All associated event listeners registered for the given event name will be invoked asynchronously.

      Type Parameters

      • Name extends string

      Parameters

      • eventName: Name

        The name of the event.

      • ...value: Params<Events[Name]>

        The event value. Passed to all event listeners. Note: no value can be passed if the event type is void.

      Returns void