@mendix/extensions-api - v0.2.4
    Preparing search index...

    Interface IComponentApi<EventMap>

    Every component API must implement this interface, which is usually done by inheriting from ComponentApiBase.

    This interface exists because APIs can be distributed by an interface alone (that inherits from this one), where the inplementation can live in another web context and is thus unknown.

    interface IComponentApi<EventMap extends Record<string, object> = {}> {
        _apiId: string;
        addEventListener<K extends string | number | symbol>(
            eventType: K,
            listener: EventHandler<EventMap, K>,
        ): DisposeListener;
        removeEventListener<K extends string | number | symbol>(
            eventType: K,
            listener: EventHandler<EventMap, K>,
        ): void;
    }

    Type Parameters

    • EventMap extends Record<string, object> = {}

      An object type that represents the events that this API can emit (keys) and the shape of their event args (types).

    Hierarchy (View Summary)

    Index

    Properties

    _apiId: string

    Unique identifier that can be used to register or retrieve a specific API.

    Example: mendix.EditorsAPI, mycompany.MyFunkyAPI

    Methods

    • Adds an event listener for the specified event type.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • eventType: K

        The type of event to listen for.

      • listener: EventHandler<EventMap, K>

        The event listener to add.

      Returns DisposeListener

      A function that can be called to remove the event listener.

    • Removes an event listener for the specified event type.

      Type Parameters

      • K extends string | number | symbol

      Parameters

      • eventType: K

        The type of event to remove the listener from.

      • listener: EventHandler<EventMap, K>

        The event listener to remove.

      Returns void