summaryrefslogtreecommitdiff
path: root/themes/blowfish/assets/lib/mermaid/utils/imperativeState.d.ts
blob: aa0de7e1ff31143f80f993248be2f926bea120ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * Resettable state storage.
 * @example
 * ```
 * const state = new ImperativeState(() => {
 *   foo: undefined as string | undefined,
 *   bar: [] as number[],
 *   baz: 1 as number | undefined,
 * });
 *
 * state.records.foo = "hi";
 * console.log(state.records.foo); // prints "hi";
 * state.reset();
 * console.log(state.records.foo); // prints "default";
 *
 * // typeof state.records:
 * // {
 * //   foo: string | undefined, // actual: undefined
 * //   bar: number[],           // actual: []
 * //   baz: number | undefined, // actual: 1
 * // }
 * ```
 */
export declare class ImperativeState<S extends Record<string, unknown>> {
    private init;
    records: S;
    /**
     * @param init - Function that creates the default state.
     */
    constructor(init: () => S);
    reset(): void;
}