Skip to content
On this page

biSyncRef

Category
Last Changed
3 months ago

Two-way refs synchronization.

Demo

Usage

import { biSyncRef } from '@vueuse/core'

const a = ref('a')
const b = ref('b')

const stop = biSyncRef(a, b)

console.log(a.value) // a

b.value = 'foo'

console.log(a.value) // foo

a.value = 'bar'

console.log(b.value) // bar
import { biSyncRef } from '@vueuse/core'

const a = ref('a')
const b = ref('b')

const stop = biSyncRef(a, b)

console.log(a.value) // a

b.value = 'foo'

console.log(a.value) // foo

a.value = 'bar'

console.log(b.value) // bar
  • syncRef

Type Declarations

/**
 * Two-way refs synchronization.
 *
 * @param a
 * @param b
 */
export declare function biSyncRef<R extends Ref<any>>(a: R, b: R): () => void
/**
 * Two-way refs synchronization.
 *
 * @param a
 * @param b
 */
export declare function biSyncRef<R extends Ref<any>>(a: R, b: R): () => void

Source

SourceDemoDocs

Contributors

Anthony Fu
Daiki Ojima
Antério Vieira

Changelog

No recent changes
biSyncRef has loaded