UNPKG

1.35 kBTypeScriptView Raw
1import { Atom, SetAtom, WritableAtom } from './atom';
2import { ExtractAtomResult, ExtractAtomUpdate, ExtractAtomValue } from './typeUtils';
3import { useAtomValue } from './useAtomValue';
4type Scope = NonNullable<Parameters<typeof useAtomValue>[1]>;
5export declare function useAtom<Value, Update, Result extends void | Promise<void>>(atom: WritableAtom<Promise<Value>, Update, Result>, scope?: Scope): [
6 Value,
7 SetAtom<Update, Result>
8];
9export declare function useAtom<Value>(atom: Atom<Promise<Value>>, scope?: Scope): [
10 Value,
11 never
12];
13export declare function useAtom<Value, Update, Result extends void | Promise<void>>(atom: WritableAtom<Value, Update, Result>, scope?: Scope): [
14 Awaited<Value>,
15 SetAtom<Update, Result>
16];
17export declare function useAtom<Value>(atom: Atom<Value>, scope?: Scope): [
18 Awaited<Value>,
19 never
20];
21export declare function useAtom<AtomType extends WritableAtom<any, any, void | Promise<void>>>(atom: AtomType, scope?: Scope): [
22 Awaited<ExtractAtomValue<AtomType>>,
23 SetAtom<ExtractAtomUpdate<AtomType>, ExtractAtomResult<AtomType>>
24];
25export declare function useAtom<AtomType extends Atom<any>>(atom: AtomType, scope?: Scope): [
26 Awaited<ExtractAtomValue<AtomType>>,
27 never
28];
29export {};
30declare type Awaited<T> = T extends Promise<infer V> ? V : T;
\No newline at end of file