1 | type Getter = <Value>(atom: Atom<Value>) => Value;
|
2 | type Setter = <Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, ...args: Args) => Result;
|
3 | type SetAtom<Args extends unknown[], Result> = <A extends Args>(...args: A) => Result;
|
4 | type Read<Value, SetSelf = never> = (get: Getter, options: {
|
5 | readonly signal: AbortSignal;
|
6 | readonly setSelf: SetSelf;
|
7 | }) => Value;
|
8 | type Write<Args extends unknown[], Result> = (get: Getter, set: Setter, ...args: Args) => Result;
|
9 | type WithInitialValue<Value> = {
|
10 | init: Value;
|
11 | };
|
12 | type OnUnmount = () => void;
|
13 | type OnMount<Args extends unknown[], Result> = <S extends SetAtom<Args, Result>>(setAtom: S) => OnUnmount | void;
|
14 | export interface Atom<Value> {
|
15 | toString: () => string;
|
16 | read: Read<Value>;
|
17 | debugLabel?: string;
|
18 | |
19 |
|
20 |
|
21 |
|
22 | debugPrivate?: boolean;
|
23 | }
|
24 | export interface WritableAtom<Value, Args extends unknown[], Result> extends Atom<Value> {
|
25 | read: Read<Value, SetAtom<Args, Result>>;
|
26 | write: Write<Args, Result>;
|
27 | onMount?: OnMount<Args, Result>;
|
28 | }
|
29 | type SetStateAction<Value> = Value | ((prev: Value) => Value);
|
30 | export type PrimitiveAtom<Value> = WritableAtom<Value, [
|
31 | SetStateAction<Value>
|
32 | ], void>;
|
33 | export declare function atom<Value, Args extends unknown[], Result>(read: Read<Value, SetAtom<Args, Result>>, write: Write<Args, Result>): WritableAtom<Value, Args, Result>;
|
34 | export declare function atom<Value>(read: Read<Value>): Atom<Value>;
|
35 | export declare function atom<Value, Args extends unknown[], Result>(initialValue: Value, write: Write<Args, Result>): WritableAtom<Value, Args, Result> & WithInitialValue<Value>;
|
36 | export declare function atom<Value>(initialValue: Value): PrimitiveAtom<Value> & WithInitialValue<Value>;
|
37 | export {};
|
38 |
|
\ | No newline at end of file |