Options
All
  • Public
  • Public/Protected
  • All
Menu

Stores and manages mutable program state that can change at runtime and persists between page reloads. Allows watchers to be notified when data changes.

Hierarchy

  • ISettings

Index

Methods

addWatcher

  • addWatcher(dataId: string, watcher: (newValue: unknown) => void): void
  • addWatcher(dataId: string, watcher: (newValue: unknown) => void, callOnAdd: boolean): void
  • Register a function to call when certain data changes and call that function immediately after registering it

    Parameters

    • dataId: string

      ID to watch for changes on

    • watcher: (newValue: unknown) => void

      Function to call when data changes

        • (newValue: unknown): void
        • Parameters

          • newValue: unknown

          Returns void

    Returns void

  • Register a function to call when certain data changes

    Parameters

    • dataId: string

      ID to watch for changes on

    • watcher: (newValue: unknown) => void

      Function to call when data changes

        • (newValue: unknown): void
        • Parameters

          • newValue: unknown

          Returns void

    • callOnAdd: boolean

      If true, calls the watcher immediately after registering it

    Returns void

getAllSettingNames

  • getAllSettingNames(): string[]
  • Get all setting IDs

    Returns string[]

getData

  • getData(id: string): Option<unknown>
  • See the current value associated with an ID. However, addWatcher should be used instead when possible.

    Parameters

    • id: string

    Returns Option<unknown>

removeWatcher

  • removeWatcher(dataId: string, watcher: (newValue: unknown) => void): void
  • Unregister a watcher so it is no longer called when certain data is updated

    Parameters

    • dataId: string
    • watcher: (newValue: unknown) => void
        • (newValue: unknown): void
        • Parameters

          • newValue: unknown

          Returns void

    Returns void

setDefault

  • setDefault(id: string, defaultValue: unknown): void
  • Sets an initial value for data only if the data wasn't already initialized

    Parameters

    • id: string
    • defaultValue: unknown

    Returns void

updateData

  • updateData(id: string, data: unknown): void
  • Sets the data stored at id to the new data. Calls relevant watchers.

    Parameters

    • id: string
    • data: unknown

    Returns void

Generated using TypeDoc