@companion-module/base
    Preparing search index...

    Interface CompanionActionDefinition<TOptions>

    The definition of an action

    interface CompanionActionDefinition<
        TOptions extends CompanionOptionValues = CompanionOptionValues,
    > {
        callback: (
            action: CompanionActionEvent<TOptions>,
            context: CompanionActionContext,
        ) => void | Promise<void>;
        description?: string;
        learn?: (
            action: CompanionActionEvent<TOptions>,
            context: CompanionActionContext,
        ) => Partial<TOptions> | Promise<Partial<TOptions> | undefined> | undefined;
        learnTimeout?: number;
        name: string;
        options: SomeCompanionActionInputField<Extract<keyof TOptions, string>>[];
        optionsToMonitorForSubscribe?: Extract<keyof TOptions, string>[];
        skipUnsubscribeOnOptionsChange?: boolean;
        sortName?: string;
        subscribe?: (
            action: CompanionActionInfo<TOptions>,
            context: CompanionActionContext,
        ) => void | Promise<void>;
        unsubscribe?: (
            action: CompanionActionInfo<TOptions>,
            context: CompanionActionContext,
        ) => void | Promise<void>;
    }

    Type Parameters

    Index

    Properties

    callback: (
        action: CompanionActionEvent<TOptions>,
        context: CompanionActionContext,
    ) => void | Promise<void>

    Called to execute the action

    description?: string

    Additional description of the action

    learn?: (
        action: CompanionActionEvent<TOptions>,
        context: CompanionActionContext,
    ) => Partial<TOptions> | Promise<Partial<TOptions> | undefined> | undefined

    The user requested to 'learn' the values for this action. Note: As of 2.0, you should only return the values that have been learned, so that expressions in any id fields will be preserved

    learnTimeout?: number

    Timeout for the 'learn' function (in milliseconds) Companion sets a default value of 5s, to ensure that the learn does not get stuck never completing You can change this if this number does not work for you, but you should keep it to a sensible value

    name: string

    Name to show in the actions list

    options: SomeCompanionActionInputField<Extract<keyof TOptions, string>>[]

    The input fields for the action

    optionsToMonitorForSubscribe?: Extract<keyof TOptions, string>[]

    Only monitor the specified options for re-running the subscribe/unsubscribe callbacks It is recommended to set this for all actions using subscribe, to reduce unnecessary calls when the user has the values driven by expressions. If not set, all options changes will trigger unsubscribe/subscribe

    skipUnsubscribeOnOptionsChange?: boolean

    If true, the unsubscribe callback will not be called when the options change, only when the action is removed or disabled

    sortName?: string

    Alternate value to use when sorting the list of actions By default, the actions are ordered by the name field, but you can override this without altering the visible name by setting this value

    subscribe?: (
        action: CompanionActionInfo<TOptions>,
        context: CompanionActionContext,
    ) => void | Promise<void>

    Called to report the existence of an action Useful to ensure necessary data is loaded

    unsubscribe?: (
        action: CompanionActionInfo<TOptions>,
        context: CompanionActionContext,
    ) => void | Promise<void>

    Called to report an action has been edited/removed Useful to cleanup subscriptions setup in subscribe