Options
All
  • Public
  • Public/Protected
  • All
Menu

Module api/settings

Index

Type aliases

Serializable: string | number | boolean | null | {} | Serializable[]

JSON-serializable object that can be stored as the value of a setting.

SettingsCallback: (args: { setting: string; value: Serializable }) => void

Type declaration

    • Callback used to subscribe to changes in a settings category.

      Parameters

      • args: { setting: string; value: Serializable }
        • setting: string

          Key of the setting.

        • value: Serializable

          Value of the setting.

      Returns void

Functions

  • connectComponent(component: ComponentType<{}>, file: string): React.ComponentType
  • Wrap a React component so that it will be rerendered whenever a setting is changed in a category.

    The component will have a prop, settings, that is a SettingsStore for the specified category.

    Parameters

    • component: ComponentType<{}>

      Component to wrap.

    • file: string

      Settings category.

    Returns React.ComponentType

    Wrapped component.

  • connectStores(component: ComponentType<{}>, file: string): React.ComponentType
  • Wrap a React component so that it will be rerendered whenever any setting for any Enmity category is changed.

    The component will have a prop, settings, that is a SettingsStore for the specified category.

    Do not use this unless you need integration with other plugins. Prefer connectComponent to avoid needless performance impacts.

    Parameters

    • component: ComponentType<{}>

      Component to wrap.

    • file: string

      Settings category.

    Returns React.ComponentType

    Wrapped component.

  • Get a setting.

    Parameters

    • file: string

      Category of the setting.

    • setting: string

      Key of the setting.

    • Optional defaults: Serializable

      Default value to use if the setting does not exist.

    Returns Serializable

    Value of the setting.

  • getBoolean(file: string, setting: string, defaults?: boolean): boolean
  • Get a setting as a boolean.

    Parameters

    • file: string

      Category of the setting.

    • setting: string

      Key of the setting.

    • Optional defaults: boolean

      Default value to use if the setting does not exist.

    Returns boolean

    Value of the setting as a boolean.

  • set(file: string, setting: string, value: Serializable): void
  • Set a setting.

    Parameters

    • file: string

      Category of the setting.

    • setting: string

      Key of the setting.

    • value: Serializable

      Value of the setting.

    Returns void

  • Subscribe to changes to settings in a category.

    Parameters

    • file: string

      Settings category.

    • callback: SettingsCallback

      Callback to run when a setting is updated.

    Returns void

  • toggle(file: string, setting: string, defaults?: boolean): void
  • Toggle a setting.

    Parameters

    • file: string

      Category of the setting.

    • setting: string

      Key of the setting.

    • Optional defaults: boolean

      Default value to use if the setting does not exist.

    Returns void

  • Unsubscribe from changes to settings in a category.

    Parameters

    • file: string

      Settings category.

    • callback: SettingsCallback

      Callback to run when a setting is updated.

    Returns void

Generated using TypeDoc