# FakeDevicePreferences

Scripted [`DevicePreferences`](https://docs.mapcairn.com/api/core/DevicePreferences.md).

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

## Signature

```ts
import { FakeDevicePreferences } from "@mapcairn/core";
 
class FakeDevicePreferences implements DevicePreferences
```

## Description

How to script it: pass the starting values (no reduced motion, fine pointer,
no languages and online by default) and call `set(patch)` to change them.
Subscribers are notified only when a value actually changes, and `get()`
returns the same object until then.

## Constructors

### (constructor)

```ts
constructor(initial?: Partial<DevicePreferencesValue>);
```

Constructs a new instance of the `FakeDevicePreferences` class

- `initial?` (`Partial<DevicePreferencesValue>`)

## Methods

### get

```ts
get(): DevicePreferencesValue;
```

The current values. The same object is returned until `set` changes one.

### set

```ts
set(patch: Partial<DevicePreferencesValue>): void;
```

Changes preferences and notifies subscribers if anything differs.

- `patch` (`Partial<DevicePreferencesValue>`)

### subscribe

```ts
subscribe(listener: (value: DevicePreferencesValue) => void): () => void;
```

Calls the listener when `set` changes a value. Returns the function that unsubscribes.

- `listener` (`(value: DevicePreferencesValue) => void`)

## See also

- [`DevicePreferences`](https://docs.mapcairn.com/api/core/DevicePreferences.md)
- [`DevicePreferencesValue`](https://docs.mapcairn.com/api/core/DevicePreferencesValue.md)

Source: [packages/core/src/fakes/FakeDevicePreferences.ts:16](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/fakes/FakeDevicePreferences.ts#L16)
