Skip to content
On this page

resolveRef

Category
Export Size
188 B
Last Changed
3 months ago
Related

Normalize value/ref/getter to ref or computed.

Usage

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

/**
 * 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

SourceDocs

Contributors

Anthony Fu

Changelog

v8.9.1 on 7/8/2022
a9ccc - feat(all): use MaybeComputedRef (#1768)
v8.8.0 on 7/6/2022
29fd5 - feat: new function (#1743)

Released under the MIT License.