reset-ref
v0.2.0
Published
A Vue 3 Composition API utility to create resettable ref.
Downloads
11
Maintainers
Readme
reset-ref
A Vue 3 Composition API utility to create resettable ref.
Install
npm install reset-ref
Usage
import { resetRef, useReset } from 'reset-ref'
const [user, resetUser] = resetRef({ id: 1, name: 'test' }) // or useReset({id:1, name:'test'})
user.value.name = 'new name' // user.value is now {id:1, name:'new name'}
resetUser() // user.value is now {id:1, name:'test'}
resetUser.$patch({ name: 'admin' }) // user.value is now {id:1, name:'admin'}
console.log(resetUser.defaults) // defaults is {id:1, name:'test'}