Skip to main content

MemorySettingsStore

An in-memory SettingsStore.

This is a class exported by @mapcairn/core, checked against version 0.2.0.

Signature​

import { MemorySettingsStore } from "@mapcairn/core";

class MemorySettingsStore implements SettingsStore

Description​

How to script it: pass persistent: false to simulate blocked storage and initial to start from non-default settings. get() returns the same frozen object until a set changes a value (compared with Object.is), so a no-op set neither notifies nor changes the reference. Properties in a patch whose value is undefined are ignored.

Constructors​

(constructor)​

constructor(options?: MemorySettingsStoreOptions);

Constructs a new instance of the MemorySettingsStore class

  • options? (MemorySettingsStoreOptions)

Properties​

persistent​

readonly persistent: boolean;

Whether changes would survive a reload, as the constructor option set it.

Methods​

get​

get(): Settings;

The current settings, a frozen object that stays the same until a set changes a value.

set​

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

Merges the patch, ignoring properties whose value is undefined. It notifies only when a value changed.

  • patch (Partial<Settings>)

subscribe​

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

Calls the listener with the new settings after a change. Returns the function that unsubscribes.

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

See also​

Source: packages/core/src/fakes/MemorySettingsStore.ts:37