1 | declare type Awaited<T> = T extends Promise<infer V> ? Awaited<V> : T;
|
2 | declare type Getter = {
|
3 | <Value>(atom: Atom<Value | Promise<Value>>): Value;
|
4 | <Value>(atom: Atom<Promise<Value>>): Value;
|
5 | <Value>(atom: Atom<Value>): Awaited<Value>;
|
6 | };
|
7 | declare type WriteGetter = Getter & {
|
8 | <Value>(atom: Atom<Value | Promise<Value>>, options: {
|
9 | unstable_promise: true;
|
10 | }): Promise<Value> | Value;
|
11 | <Value>(atom: Atom<Promise<Value>>, options: {
|
12 | unstable_promise: true;
|
13 | }): Promise<Value> | Value;
|
14 | <Value>(atom: Atom<Value>, options: {
|
15 | unstable_promise: true;
|
16 | }): Promise<Awaited<Value>> | Awaited<Value>;
|
17 | };
|
18 | declare type Setter = {
|
19 | <Value, Result extends void | Promise<void>>(atom: WritableAtom<Value, undefined, Result>): Result;
|
20 | <Value, Update, Result extends void | Promise<void>>(atom: WritableAtom<Value, Update, Result>, update: Update): Result;
|
21 | };
|
22 | declare type Read<Value> = (get: Getter) => Value;
|
23 | declare type Write<Update, Result extends void | Promise<void>> = (get: WriteGetter, set: Setter, update: Update) => Result;
|
24 | declare type WithInitialValue<Value> = {
|
25 | init: Value;
|
26 | };
|
27 | export declare type Scope = symbol | string | number;
|
28 | export declare type SetAtom<Update, Result extends void | Promise<void>> = undefined extends Update ? (update?: Update) => Result : (update: Update) => Result;
|
29 | declare type OnUnmount = () => void;
|
30 | declare type OnMount<Update, Result extends void | Promise<void>> = <S extends SetAtom<Update, Result>>(setAtom: S) => OnUnmount | void;
|
31 | export declare type Atom<Value> = {
|
32 | toString: () => string;
|
33 | debugLabel?: string;
|
34 | read: Read<Value>;
|
35 | };
|
36 | export declare type WritableAtom<Value, Update, Result extends void | Promise<void> = void> = Atom<Value> & {
|
37 | write: Write<Update, Result>;
|
38 | onMount?: OnMount<Update, Result>;
|
39 | };
|
40 | declare type SetStateAction<Value> = Value | ((prev: Value) => Value);
|
41 | export declare type PrimitiveAtom<Value> = WritableAtom<Value, SetStateAction<Value>>;
|
42 | export declare function atom<Value, Update, Result extends void | Promise<void> = void>(read: Read<Value>, write: Write<Update, Result>): WritableAtom<Value, Update, Result>;
|
43 | export declare function atom<Value>(read: Read<Value>): Atom<Value>;
|
44 | export declare function atom(invalidFunction: (...args: any) => any, write?: any): never;
|
45 | export declare function atom<Value, Update, Result extends void | Promise<void> = void>(initialValue: Value, write: Write<Update, Result>): WritableAtom<Value, Update, Result> & WithInitialValue<Value>;
|
46 | export declare function atom<Value>(initialValue: Value): PrimitiveAtom<Value> & WithInitialValue<Value>;
|
47 | export {};
|
48 |
|
\ | No newline at end of file |