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)
ParameterTypeDescription
schemaPreferenceSchema<T>
store?KeyValueStore

Accessors

NameTypeDescription
valuegetReadonly<T>

Methods

update

update(patch: Partial<T>): void

Apply 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.

ParameterTypeDescription
patchPartial<T>

subscribe

subscribe(listener: (value: Readonly<T>) => void): () => void

Returns an unsubscribe function.

ParameterTypeDescription
listener(value: Readonly<T>) => void

reset

reset(): void

Back to the declared defaults, persisted and announced like any change.