/** * `whenIdle` and `useAsync` lifecycle / async helpers. * * @module bquery/component */ import type { Signal } from '../reactive/index'; /** * Schedule a callback to run when the browser is idle. * * Uses `requestIdleCallback` when available with a fallback to * `setTimeout(fn, 1)`. The pending callback is canceled automatically when the * component disconnects. Returns a manual cancel function. * * @example * ```ts * connected() { * whenIdle(() => prefetchHeavyData()); * } * ``` */ export declare const whenIdle: (callback: () => void) => (() => void); /** * Result shape returned by {@link useAsync}. */ export type UseAsyncResult = { data: Signal; error: Signal; loading: Signal; refresh: () => Promise; }; /** * Run an async function with reactive `data`, `error`, and `loading` signals. * * The async function receives an `AbortSignal`; if the component disconnects * (or `refresh()` is called again) the previous run is aborted via the standard * `AbortController` protocol. * * @example * ```ts * connected() { * const { data, error, loading, refresh } = useAsync(async (signal) => { * const res = await fetch('/api/me', { signal }); * return res.json(); * }); * this._refresh = refresh; * } * ``` */ export declare const useAsync: (fn: (signal: AbortSignal) => Promise) => UseAsyncResult; //# sourceMappingURL=async.d.ts.map