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

    Interface ISnippetApi

    API for working with snippets

    interface ISnippetApi {
        _apiId: "mendix.SnippetApi";
        addEventListener<K extends never>(
            eventType: K,
            listener: EventHandler<{}, K>,
        ): DisposeListener;
        addSnippet(
            containerId: string,
            options?: SnippetCreationOptions,
        ): Promise<Snippet>;
        applyChanges(operations: Operation[]): Promise<ApplyChangesResult>;
        createElement<TElement extends ElementBase>(
            type: TElement["$Type"],
            options?: TElement["$CreationOptions"],
        ): Promise<TElement>;
        createUnit(
            type: "Pages$Snippet",
            containerId: string,
            options?: SnippetCreationOptions,
        ): Promise<Snippet>;
        deleteUnit(unitId: string): Promise<void>;
        getElementMetadata(): Promise<ElementMetadataMap>;
        loadUnits(type: "Pages$Snippet", unitIds: string[]): Promise<Snippet[]>;
        removeEventListener<K extends never>(
            eventType: K,
            listener: EventHandler<{}, K>,
        ): void;
    }

    Hierarchy

    • IModelComponentApiBase<Snippet>
      • ISnippetApi
    Index

    Properties

    _apiId: "mendix.SnippetApi"

    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 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.

    • Adds a snippet to the specified container.

      Parameters

      • containerId: string

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

      • Optionaloptions: SnippetCreationOptions

        Options for that will be used during the snippet initilization.

      Returns Promise<Snippet>

      A promise that resolves to the newly created snippet.

    • Parameters

      • operations: Operation[]

      Returns Promise<ApplyChangesResult>

    • Parameters

      Returns Promise<Snippet>

    • Parameters

      • unitId: string

      Returns Promise<void>

    • Returns Promise<ElementMetadataMap>

    • Parameters

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

      Returns Promise<Snippet[]>

    • 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