Interface IBuildingBlockApi

API for working with building blocks

interface IBuildingBlockApi {
    _apiId: "mendix.BuildingBlockApi";
    addBuildingBlock(containerId: string, options?: BuildingBlockCreationOptions): Promise<string>;
    addEventListener<K>(eventType: K, listener: EventHandler<{}, K>): DisposeListener;
    applyChanges(operations: Operation[]): Promise<ApplyChangesResult>;
    createElement<TElement>(type: TElement["$Type"], options?: TElement["$CreationOptions"]): Promise<TElement>;
    createUnit(type: "Pages$BuildingBlock", containerId: string, options?: BuildingBlockCreationOptions): Promise<BuildingBlock>;
    deleteUnit(unitId: string): Promise<void>;
    getElementMetadata(): Promise<ElementMetadataMap>;
    loadUnits(type: "Pages$BuildingBlock", unitIds: string[]): Promise<BuildingBlock[]>;
    removeEventListener<K>(eventType: K, listener: EventHandler<{}, K>): void;
}

Hierarchy

Properties

_apiId

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

Example: mendix.EditorsAPI, mycompany.MyFunkyAPI

Methods

  • Adds a building block to the specified container.

    Parameters

    • containerId: string

      The ID of the container where the building block will be added. It could be a module or folder.

    • Optionaloptions: BuildingBlockCreationOptions

      Options for that will be used during the building block initilization.

    Returns Promise<string>

    A promise that resolves to the ID of the newly created building block.

  • Adds an event listener for the specified event type.

    Type Parameters

    • K extends never

    Parameters

    • eventType: K

      The type of event to listen for.

    • listener: EventHandler<{}, K>

      The event listener to add.

    Returns DisposeListener

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

  • Parameters

    • operations: Operation[]

    Returns Promise<ApplyChangesResult>

  • Type Parameters

    Parameters

    Returns Promise<TElement>

  • Parameters

    • unitId: string

    Returns Promise<void>

  • Returns Promise<ElementMetadataMap>

  • Parameters

    • type: "Pages$BuildingBlock"
    • unitIds: string[]

    Returns Promise<BuildingBlock[]>

  • Removes an event listener for the specified event type.

    Type Parameters

    • K extends never

    Parameters

    • eventType: K

      The type of event to remove the listener from.

    • listener: EventHandler<{}, K>

      The event listener to remove.

    Returns void