# MemorySettingsStore

An in-memory [`SettingsStore`](https://docs.mapcairn.com/api/core/SettingsStore.md).

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

## Signature

```ts
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)

```ts
constructor(options?: MemorySettingsStoreOptions);
```

Constructs a new instance of the `MemorySettingsStore` class

- `options?` (`MemorySettingsStoreOptions`)

## Properties

### persistent

```ts
readonly persistent: boolean;
```

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

## Methods

### get

```ts
get(): Settings;
```

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

### set

```ts
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

```ts
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

- [`SettingsStore`](https://docs.mapcairn.com/api/core/SettingsStore.md)
- [`MemorySettingsStoreOptions`](https://docs.mapcairn.com/api/core/MemorySettingsStoreOptions.md)
- [`Settings`](https://docs.mapcairn.com/api/core/Settings.md)

Source: [packages/core/src/fakes/MemorySettingsStore.ts:37](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/fakes/MemorySettingsStore.ts#L37)
