infinity-forge
Version:
35 lines (34 loc) • 1 kB
TypeScript
import { queryStore } from './store.js';
type QueryStoreProps<T = any> = {
event?: string;
cache?: {
[key: string]: QueryState<T>;
};
queryClient?: any;
};
export type FetcherParams = {
get?: () => QueryStoreState;
};
export type QueryState<T = any> = {
data?: T;
isFetching?: boolean;
isLoading?: boolean;
mutate?: (params?: FetcherParams & any) => void;
error?: any;
changeCache?: (data: any) => void;
};
export type QueryOptions = {
enableCache?: boolean;
interval?: number;
enabled?: boolean;
};
interface QueryStoreState<T = any> extends QueryStoreProps {
clearCache: () => void;
refetch: <E>(value?: string, configs?: {
mode?: 'include' | 'exact';
}) => Promise<E | null>;
clearCacheBySubstring: (value: string) => void;
mutate: (key: string, value?: QueryState<T>) => QueryState<any>;
}
type QueryStoreType = ReturnType<typeof queryStore>;
export type { QueryStoreProps, QueryStoreState, QueryStoreType };