Provides an accessible JS object that is updated reactively from all or subset of TJSGameSettings stores. Accessors are provided to directly get / set current setting data. Using a setter will update the setting and backing store.

TJSLiveGameSettings is also a readable Svelte store essentially providing a customizable derived store of all settings tracked.

Note: You can create a JSDoc / @typedef to apply with @type and achieve typing support in IDEs for the customizable live settings instance. Please see the example at the end of this source file on how to accomplish this task.

Note: Presently TJSLiveGameSettings is openly typed, but there will be a TypeScript friendly way to strongly type additional instance properties.

Note: When using from JS a second subscriber function argument is the key that was updated. From Svelte: Use 'lastKey' accessor to retrieve the last updated key.

Note: In the future this class will be reworked w/ Svelte 5 state handling.

// Example of creating a typedef to type your specific live game settings instance. Add all relevant `@property`
// entries.

/**
* @typedef {TJSLiveGameSettings} MyLiveGameSettings - Extend TJSLiveGameSettings and name this anything.
*
* @property {boolean} myBooleanSetting - Add property / type entries for setting keys associated w/ accessors.
*/

/** @type {MyLiveGameSettings} */
const liveGameSettings = new TJSLiveGameSettings(gameSettings);
liveGameSettings.myBooleanSetting is now typed as a boolean.

Indexable

  • [key: string]: any

Constructors

  • Creates a live binding against the setting stores. All settings are configured by default, but can also be filtered by setting key with inclusive / exclusive Sets.

    Parameters

    • gameSettings: TJSGameSettings

      A game settings instance to subscribe to...

    • Optionaloptions: { exclude?: Set<string>; include?: Set<string> }

      TJSLiveGameSettings options.

      • Optionalexclude?: Set<string>

        A Set of setting keys to exclude from subscribing.

      • Optionalinclude?: Set<string>

        A Set of setting keys to include from subscribing.

    Returns TJSLiveGameSettings

Accessors

  • get lastKey(): string
  • Returns string

    Last updated setting key.

Methods

  • Override to respond to setting update.

    Parameters

    • key: string

      The setting / local key that updated.

    Returns void

  • Destroys this instance of TJSLiveGameSettings and unsubscribes from all game setting stores.

    Returns void

  • Returns an iterator / generator of all setting entries.

    Returns IterableIterator<[key: string, value: any]>

    An iterator returning setting entries.

  • Returns a string / JSON stringify of the current setting data.

    Returns string

    Tracked setting data.