Skip to main content

SettingsStore

Remembers settings. Implementations never throw, even when storage is blocked; they fall back to memory and report persistent: false so the ui can say changes will not be remembered.

This is an interface exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import type { SettingsStore } from "@mapcairn/core";

interface SettingsStore

Properties​

persistent​

readonly persistent: boolean;

False when changes will be lost on reload.

Methods​

get​

get(): Settings;

The current settings. The same object is returned until something changes.

set​

set(patch: Partial<Settings>): void;

Merges the patch into the settings. A property whose value is undefined is ignored, and a change that alters nothing notifies nobody.

  • patch (Partial<Settings>)

subscribe​

subscribe(listener: (settings: Settings) => void): () => void;

Calls the listener after a change. Returns the function that unsubscribes.

  • listener ((settings: Settings) => void)

See also​

Source: packages/core/src/ports/settings.ts:60