import type { TQueryFetcher, TQueryKey, TQueryOptions, TQueryStore } from "./types.js"; /** * Creates a reactive query for async data fetching with caching and automatic revalidation * * @param key Unique identifier for the query, can be reactive function * @param fetcher Async function to fetch data * @param options Query configuration options * @returns Query store with reactive states and control methods * * @example * Basic usage: * ```typescript * const usersQuery = query('users', async () => { * const res = await fetch('/api/users'); * return res.json(); * }); * * // Use in component * effect(() => { * if (usersQuery.data.value) { * console.log(usersQuery.data.value); * } * }); * ``` * * @example * With options: * ```typescript * const todosQuery = query('todos', fetchTodos, { * staleTime: 5000, * cacheTime: 300000, * refetchOnFocus: true, * retry: 3 * }); * ``` * * @example * Reactive key: * ```typescript * const userId = state(1); * const userQuery = query( * () => `user-${userId.value}`, * async () => { * const res = await fetch(`/api/users/${userId.value}`); * return res.json(); * } * ); * ``` */ export declare function query(key: TQueryKey, fetcher: TQueryFetcher, options?: TQueryOptions): TQueryStore;