import type { Lazy } from "../../util/lazy"; export type FetchState = { isLoading: true; error?: undefined; data?: undefined; } | { isLoading: false; error: Error; data?: undefined; } | { isLoading: false; error?: undefined; data: T; }; export type UseFetchCache = { set: (key: string, value: T) => void; get: (key: string) => T | undefined; delete: (key: string) => void; }; export type CacheValue = { data: T; error: undefined; } | { data: undefined; error: Error; }; export type UseFetchResult = FetchState & { mutate: () => void; }; export declare const useFetchExternalCache: (key: Lazy, fetcher: (args: TKey) => Promise, cache: UseFetchCache>) => UseFetchResult; /** * キーに対応するデータを非同期に取得するためのhook * 同じキーに対応するデータはキャッシュされる * useFetchを使う限り、キャッシュはhook呼び出し単位で保持される * useFetchExternalCacheを使うと、キャッシュを外部で管理できる * @param key * @param fetcher */ export declare const useFetch: (key: Lazy, fetcher: (args: TKey) => Promise) => UseFetchResult; export declare const keyToCacheKey: (key: unknown) => string; //# sourceMappingURL=useFetch.d.ts.map