1 | import { Atom, WritableAtom } from './atom';
|
2 | type AnyValue = unknown;
|
3 | type AnyError = unknown;
|
4 | type AnyAtom = Atom<AnyValue>;
|
5 | type OnUnmount = () => void;
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | type Dependencies = Map<AnyAtom, AtomState>;
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | type AtomState<Value = AnyValue> = {
|
18 | d: Dependencies;
|
19 | } & ({
|
20 | e: AnyError;
|
21 | } | {
|
22 | v: Value;
|
23 | });
|
24 | type Listeners = Set<() => void>;
|
25 | type Dependents = Set<AnyAtom>;
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | type Mounted = {
|
34 |
|
35 | l: Listeners;
|
36 |
|
37 | t: Dependents;
|
38 |
|
39 | u?: OnUnmount;
|
40 | };
|
41 | type StateListener = () => void;
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | export declare const createStore: () => {
|
59 | get: <Value>(atom: Atom<Value>) => Value;
|
60 | set: <Value_1, Args extends unknown[], Result>(atom: WritableAtom<Value_1, Args, Result>, ...args: Args) => Result;
|
61 | sub: (atom: AnyAtom, listener: () => void) => () => void;
|
62 | res: (values: Iterable<readonly [
|
63 | AnyAtom,
|
64 | AnyValue
|
65 | ]>) => void;
|
66 | dev_subscribe_state: (l: StateListener) => () => void;
|
67 | dev_get_mounted_atoms: () => IterableIterator<AnyAtom>;
|
68 | dev_get_atom_state: (a: AnyAtom) => AtomState<unknown> | undefined;
|
69 | dev_get_mounted: (a: AnyAtom) => Mounted | undefined;
|
70 | } | {
|
71 | get: <Value>(atom: Atom<Value>) => Value;
|
72 | set: <Value_1, Args extends unknown[], Result>(atom: WritableAtom<Value_1, Args, Result>, ...args: Args) => Result;
|
73 | sub: (atom: AnyAtom, listener: () => void) => () => void;
|
74 | res: (values: Iterable<readonly [
|
75 | AnyAtom,
|
76 | AnyValue
|
77 | ]>) => void;
|
78 | dev_subscribe_state?: never;
|
79 | dev_get_mounted_atoms?: never;
|
80 | dev_get_atom_state?: never;
|
81 | dev_get_mounted?: never;
|
82 | };
|
83 | export declare const getDefaultStore: () => {
|
84 | get: <Value>(atom: Atom<Value>) => Value;
|
85 | set: <Value_1, Args extends unknown[], Result>(atom: WritableAtom<Value_1, Args, Result>, ...args: Args) => Result;
|
86 | sub: (atom: AnyAtom, listener: () => void) => () => void;
|
87 | res: (values: Iterable<readonly [
|
88 | AnyAtom,
|
89 | AnyValue
|
90 | ]>) => void;
|
91 | dev_subscribe_state: (l: StateListener) => () => void;
|
92 | dev_get_mounted_atoms: () => IterableIterator<AnyAtom>;
|
93 | dev_get_atom_state: (a: AnyAtom) => AtomState<unknown> | undefined;
|
94 | dev_get_mounted: (a: AnyAtom) => Mounted | undefined;
|
95 | } | {
|
96 | get: <Value>(atom: Atom<Value>) => Value;
|
97 | set: <Value_1, Args extends unknown[], Result>(atom: WritableAtom<Value_1, Args, Result>, ...args: Args) => Result;
|
98 | sub: (atom: AnyAtom, listener: () => void) => () => void;
|
99 | res: (values: Iterable<readonly [
|
100 | AnyAtom,
|
101 | AnyValue
|
102 | ]>) => void;
|
103 | dev_subscribe_state?: never;
|
104 | dev_get_mounted_atoms?: never;
|
105 | dev_get_atom_state?: never;
|
106 | dev_get_mounted?: never;
|
107 | };
|
108 | export {};
|
109 | declare type Awaited<T> = T extends Promise<infer V> ? V : T; |
\ | No newline at end of file |