FakeThemeSource
A scripted ThemeSource.
This is a class exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { FakeThemeSource } from "@mapcairn/core";
class FakeThemeSource implements ThemeSource
Description
How to script it: pass the starting system theme (light by default) and
call setSystemTheme(theme) to change it. Subscribers are notified only
when the theme actually changes, like a media query. apply notifies
nobody; it records the theme in appliedTheme (null until first applied)
and every call in applyCalls.
Constructors
(constructor)
constructor(systemTheme?: ResolvedTheme);
Constructs a new instance of the FakeThemeSource class
systemTheme?(ResolvedTheme)
Properties
appliedTheme
readonly get appliedTheme(): ResolvedTheme | null;
The last theme passed to apply, or null if none has been.
applyCalls
readonly applyCalls: ResolvedTheme[];
Every theme passed to apply, in order.
Methods
apply
apply(theme: ResolvedTheme): void;
Records the theme in appliedTheme and applyCalls. It notifies nobody.
theme(ResolvedTheme)
getSystemTheme
getSystemTheme(): ResolvedTheme;
The system theme as scripted, light until setSystemTheme changes it.
setSystemTheme
setSystemTheme(theme: ResolvedTheme): void;
Changes the system theme and notifies subscribers if it differs.
theme(ResolvedTheme)
subscribe
subscribe(listener: (theme: ResolvedTheme) => void): () => void;
Calls the listener when setSystemTheme changes the theme. Returns the function that unsubscribes.
listener((theme: ResolvedTheme) => void)