UNPKG

638 BTypeScriptView Raw
1import { Setter, WritableAtom } from 'jotai';
2import { Scope } from '../core/atom';
3declare type WriteGetter = Parameters<WritableAtom<unknown, unknown>['write']>[0];
4declare type Callback<Result, Arg> = undefined extends Arg ? (arg?: Arg) => Result : (arg: Arg) => Result;
5export declare function useAtomCallback<Result, Arg>(callback: (get: WriteGetter, set: Setter, arg: Arg) => Promise<Result>, scope?: Scope): Callback<Promise<Result>, Arg>;
6export declare function useAtomCallback<Result, Arg>(callback: (get: WriteGetter, set: Setter, arg: Arg) => Result, scope?: Scope): Callback<Result | Promise<Result>, Arg>;
7export {};