Vue 3 utility to keep multiple refs synchronized bidirectionally
npm install vue-sync-refs
A Vue 3 composition API utility that synchronizes values between refs, keeping them in sync automatically. Changes to source propagate to targets with configurable options.
``bash`
npm install vue-sync-refs
`ts
import { syncRefs } from 'vue-sync-refs'
import { ref } from 'vue'
const source = ref('hello')
const target = ref('')
syncRefs(source, target)
console.log(target.value) // 'hello'
source.value = 'world'
setTimeout(() => {
console.log(target.value) // 'world'
}, 100)
``
MIT
Extracted from VueUse for standalone use.