Class TJSLiveGameSettings
Indexable
- [key: string]: any
Constructors
constructor
- new TJSLiveGameSettings(
gameSettings: TJSGameSettings,
options?: { exclude?: Set<string>; include?: Set<string> },
): TJSLiveGameSettingsCreates 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.
Returns TJSLiveGameSettings
- gameSettings: TJSGameSettings
Methods
Protected_update
Override to respond to setting update.
Parameters
- key: string
The setting / local key that updated.
Returns void
- key: string
destroy
Destroys this instance of TJSLiveGameSettings and unsubscribes from all game setting stores.
Returns void
entries
Returns an iterator / generator of all setting entries.
Returns IterableIterator<[key: string, value: any]>
An iterator returning setting entries.
keys
Returns an iterator / generator of all setting keys.
Returns IterableIterator<string>
An iterator returning setting keys.
subscribe
Parameters
- handler: (value: TJSLiveGameSettings, key?: string) => void
Callback function that is invoked on update / changes.
Returns Unsubscriber
Unsubscribe function.
- handler: (value: TJSLiveGameSettings, key?: string) => void
toString
Returns a string / JSON stringify of the current setting data.
Returns string
Tracked setting data.
values
Returns an iterator / generator of all values.
Returns IterableIterator<any>
An iterator returning setting values.
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 /
@typedefto apply with@typeand 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
TJSLiveGameSettingsis 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