Core · class
PreferenceStore
A live preference record: the loaded value, validated updates, persistence and change notification for whatever applies them to running systems.
Explained in The loop.
class PreferenceStore<T extends object>import { PreferenceStore } from '@driftengine/core';Constructor
new
constructor(schema: PreferenceSchema<T>, store?: KeyValueStore)| Parameter | Type | Description |
|---|---|---|
schema | PreferenceSchema<T> | |
store? | KeyValueStore |
Accessors
| Name | Type | Description |
|---|---|---|
valueget | Readonly<T> |
Methods
update
update(patch: Partial<T>): voidApply a partial change. Every field goes through the same validation as a stored one — a control that can produce an illegal value would otherwise write it, leaving the read path as the only thing catching it, one boot too late.
| Parameter | Type | Description |
|---|---|---|
patch | Partial<T> |
subscribe
subscribe(listener: (value: Readonly<T>) => void): () => voidReturns an unsubscribe function.
| Parameter | Type | Description |
|---|---|---|
listener | (value: Readonly<T>) => void |
reset
reset(): voidBack to the declared defaults, persisted and announced like any change.