UNPKG

1.22 kBTypeScriptView Raw
1import type { Atom, SetAtom, WritableAtom } from './atom';
2import type { 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): [Value, SetAtom<Update, Result>];
6export declare function useAtom<Value>(atom: Atom<Promise<Value>>, scope?: Scope): [Value, never];
7export declare function useAtom<Value, Update, Result extends void | Promise<void>>(atom: WritableAtom<Value, Update, Result>, scope?: Scope): [Awaited<Value>, SetAtom<Update, Result>];
8export declare function useAtom<Value>(atom: Atom<Value>, scope?: Scope): [Awaited<Value>, never];
9export declare function useAtom<AtomType extends WritableAtom<any, any, void | Promise<void>>>(atom: AtomType, scope?: Scope): [
10 Awaited<ExtractAtomValue<AtomType>>,
11 SetAtom<ExtractAtomUpdate<AtomType>, ExtractAtomResult<AtomType>>
12];
13export declare function useAtom<AtomType extends Atom<any>>(atom: AtomType, scope?: Scope): [Awaited<ExtractAtomValue<AtomType>>, never];
14export {};