Skip to main content

FakeDevicePreferences

Scripted DevicePreferences.

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

Signature​

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)​

constructor(initial?: Partial<DevicePreferencesValue>);

Constructs a new instance of the FakeDevicePreferences class

  • initial? (Partial<DevicePreferencesValue>)

Methods​

get​

get(): DevicePreferencesValue;

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

set​

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

Changes preferences and notifies subscribers if anything differs.

  • patch (Partial<DevicePreferencesValue>)

subscribe​

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​

Source: packages/core/src/fakes/FakeDevicePreferences.ts:16