resolveRef
Normalize value/ref/getter to ref
or computed
.
Usage
ts
import { resolveRef } from '@vueuse/core'
const foo = ref('hi')
const a = resolveRef(0) // Ref<number>
const b = resolveRef(foo) // Ref<string>
const c = resolveRef(() => 'hi') // ComputedRef<string>
import { resolveRef } from '@vueuse/core'
const foo = ref('hi')
const a = resolveRef(0) // Ref<number>
const b = resolveRef(foo) // Ref<string>
const c = resolveRef(() => 'hi') // ComputedRef<string>
Type Declarations
typescript
/**
* Normalize value/ref/getter to `ref` or `computed`.
*/
export declare function resolveRef<T>(r: MaybeComputedRef<T>): ComputedRef<T>
export declare function resolveRef<T>(r: MaybeRef<T>): Ref<T>
export declare function resolveRef<T>(r: T): Ref<T>
/**
* Normalize value/ref/getter to `ref` or `computed`.
*/
export declare function resolveRef<T>(r: MaybeComputedRef<T>): ComputedRef<T>
export declare function resolveRef<T>(r: MaybeRef<T>): Ref<T>
export declare function resolveRef<T>(r: T): Ref<T>
Source
Contributors
Anthony Fu