1 | export declare type Getter = {
|
2 | <Value>(atom: Atom<Value | Promise<Value>>): Value;
|
3 | <Value>(atom: Atom<Promise<Value>>): Value;
|
4 | <Value>(atom: Atom<Value>): Value;
|
5 | };
|
6 | export declare type Setter = {
|
7 | <Value>(atom: WritableAtom<Value, undefined>): void;
|
8 | <Value, Update>(atom: WritableAtom<Value, Update>, update: Update): void;
|
9 | };
|
10 | declare type Read<Value> = (get: Getter) => Value | Promise<Value>;
|
11 | declare type Write<Update> = (get: Getter, set: Setter, update: Update) => void | Promise<void>;
|
12 | declare type WithInitialValue<Value> = {
|
13 | init: Value;
|
14 | };
|
15 | export declare type Scope = symbol | string | number;
|
16 | export declare type SetAtom<Update> = undefined extends Update ? (update?: Update) => void | Promise<void> : (update: Update) => void | Promise<void>;
|
17 | declare type OnUnmount = () => void;
|
18 | declare type OnMount<Update> = <S extends SetAtom<Update>>(setAtom: S) => OnUnmount | void;
|
19 | export declare type Atom<Value> = {
|
20 | toString: () => string;
|
21 | debugLabel?: string;
|
22 | scope?: Scope;
|
23 | read: Read<Value>;
|
24 | };
|
25 | export declare type WritableAtom<Value, Update> = Atom<Value> & {
|
26 | write: Write<Update>;
|
27 | onMount?: OnMount<Update>;
|
28 | };
|
29 | declare type SetStateAction<Value> = Value | ((prev: Value) => Value);
|
30 | export declare type PrimitiveAtom<Value> = WritableAtom<Value, SetStateAction<Value>>;
|
31 | export declare function atom<Value, Update>(read: Read<Value>, write: Write<Update>): WritableAtom<Value, Update>;
|
32 | export declare function atom<Value, Update>(initialValue: Value, write: Write<Update>): [Value] extends [Function] ? never : WritableAtom<Value, Update> & WithInitialValue<Value>;
|
33 | export declare function atom<Value>(read: Read<Value>): Atom<Value>;
|
34 | export declare function atom<Value extends unknown>(initialValue: Value): [Value] extends [Function] ? never : PrimitiveAtom<Value> & WithInitialValue<Value>;
|
35 | export {};
|
36 |
|
\ | No newline at end of file |