|
3 | 3 | * |
4 | 4 | * SPDX-License-Identifier: MIT |
5 | 5 | */ |
6 | | -import { derived, get, writable, type Subscriber, type Unsubscriber, type Writable } from 'svelte/store'; |
| 6 | +import { |
| 7 | + derived, |
| 8 | + get, |
| 9 | + writable, |
| 10 | + type Subscriber, |
| 11 | + type Unsubscriber, |
| 12 | + type Writable, |
| 13 | +} from 'svelte/store'; |
7 | 14 |
|
8 | 15 | class EnableFingerprint implements Writable<boolean> { |
9 | | - private value: Writable<boolean>; |
| 16 | + private value: Writable<boolean>; |
10 | 17 |
|
11 | | - public constructor(defaultValue: boolean) { |
12 | | - this.value = writable(defaultValue); |
13 | | - } |
| 18 | + public constructor(defaultValue: boolean) { |
| 19 | + this.value = writable(defaultValue); |
| 20 | + } |
14 | 21 |
|
15 | | - public set(newValue: boolean): void { |
16 | | - this.value.set(newValue); |
17 | | - } |
| 22 | + public set(newValue: boolean): void { |
| 23 | + this.value.set(newValue); |
| 24 | + } |
18 | 25 |
|
19 | | - public update(updater: (state: boolean) => boolean): void { |
20 | | - const beforeValue = get(this.value); |
21 | | - const updatedValue = updater(beforeValue); |
22 | | - this.set(updatedValue); |
23 | | - } |
| 26 | + public update(updater: (state: boolean) => boolean): void { |
| 27 | + const beforeValue = get(this.value); |
| 28 | + const updatedValue = updater(beforeValue); |
| 29 | + this.set(updatedValue); |
| 30 | + } |
24 | 31 |
|
25 | | - public subscribe(run: Subscriber<boolean>, invalidate?: (value?: boolean) => void): Unsubscriber { |
26 | | - return derived([this.value], ([store]) => store).subscribe(run, invalidate); |
27 | | - } |
| 32 | + public subscribe( |
| 33 | + run: Subscriber<boolean>, |
| 34 | + invalidate?: (value?: boolean) => void, |
| 35 | + ): Unsubscriber { |
| 36 | + return derived([this.value], ([store]) => store).subscribe(run, invalidate); |
| 37 | + } |
28 | 38 | } |
29 | 39 |
|
30 | 40 | export default EnableFingerprint; |
0 commit comments