UNPKG

1.06 kBTypeScriptView Raw
1import { Atom, ExtractAtomArgs, ExtractAtomResult, ExtractAtomValue, WritableAtom } from 'jotai/vanilla';
2import { useAtomValue } from './useAtomValue';
3type SetAtom<Args extends unknown[], Result> = (...args: Args) => Result;
4type Options = Parameters<typeof useAtomValue>[1];
5export declare function useAtom<Value, Args extends unknown[], Result>(atom: WritableAtom<Value, Args, Result>, options?: Options): [
6 Awaited<Value>,
7 SetAtom<Args, Result>
8];
9export declare function useAtom<Value>(atom: Atom<Value>, options?: Options): [
10 Awaited<Value>,
11 never
12];
13export declare function useAtom<AtomType extends WritableAtom<unknown, unknown[], unknown>>(atom: AtomType, options?: Options): [
14 Awaited<ExtractAtomValue<AtomType>>,
15 SetAtom<ExtractAtomArgs<AtomType>, ExtractAtomResult<AtomType>>
16];
17export declare function useAtom<AtomType extends Atom<unknown>>(atom: AtomType, options?: Options): [
18 Awaited<ExtractAtomValue<AtomType>>,
19 never
20];
21export {};
22declare type Awaited<T> = T extends Promise<infer V> ? V : T;
\No newline at end of file