import type { DeepNonNullable, DeepRequired } from 'ts-essentials'; import type { Ref } from 'vue-demi'; import type { ExtractSingleKey } from './util/ExtractSingleKey'; export type UseResultReturn = Readonly>>; /** * Resolve a `result`, returning either the first key of the `result` if there * is only one, or the `result` itself. The `value` of the ref will be * `undefined` until it is resolved. * * @example * const { result } = useQuery({}) * const user = useResult(result) * // user is `undefined` until the query resolves * * @param {Ref} result A `result` returned from `useQuery` to resolve. * @returns Readonly ref with `undefined` or the resolved `result`. * @deprecated Use `computed` instead. Before: `const items = useResult(result, [], data => data.someField.myItems)` After: `const items = computed(() => result.value?.someField.myItems ?? [])` */ export declare function useResult = keyof NonNullable>(result: Ref): UseResultReturn, TResultKey>>; /** * Resolve a `result`, returning either the first key of the `result` if there * is only one, or the `result` itself. The `value` of the ref will be * `defaultValue` until it is resolved. * * @example * const { result } = useQuery({}) * const profile = useResult(result, {}) * // profile is `{}` until the query resolves * * @param {Ref} result A `result` returned from `useQuery` to resolve. * @param {TDefaultValue} defaultValue The default return value before `result` is resolved. * @returns Readonly ref with the `defaultValue` or the resolved `result`. * @deprecated Use `computed` instead. Before: `const items = useResult(result, [], data => data.someField.myItems)` After: `const items = computed(() => result.value?.someField.myItems ?? [])` */ export declare function useResult = keyof NonNullable>(result: Ref, defaultValue: TDefaultValue): UseResultReturn, TResultKey>>; /** * Resolve a `result`, returning the `result` mapped with the `pick` function. * The `value` of the ref will be `defaultValue` until it is resolved. * * @example * const { result } = useQuery({}) * const comments = useResult(result, undefined, (data) => data.comments) * // user is `undefined`, then resolves to the result's `comments` * * @param {Ref} result A `result` returned from `useQuery` to resolve. * @param {TDefaultValue} defaultValue The default return value before `result` is resolved. * @param {(data:TResult)=>TReturnValue} pick The function that receives `result` and maps a return value from it. * @returns Readonly ref with the `defaultValue` or the resolved and `pick`-mapped `result` * @deprecated Use `computed` instead. Before: `const items = useResult(result, [], data => data.someField.myItems)` After: `const items = computed(() => result.value?.someField.myItems ?? [])` */ export declare function useResult(result: Ref, defaultValue: TDefaultValue | undefined, pick: (data: DeepRequired>) => TReturnValue): UseResultReturn;