Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/refAutoReset.md
1---2category: Reactivity3alias: autoResetRef4---56# refAutoReset78A ref which will be reset to the default value after some time.910## Usage1112```ts13import { refAutoReset } from '@vueuse/core'1415const message = refAutoReset('default message', 1000)1617function setMessage() {18// here the value will change to 'message has set' but after 1000ms, it will change to 'default message'19message.value = 'message has set'20}21```2223::: info24You can reassign the entire object to trigger updates after making deep mutations to the inner value.2526[Learn more about shallow refs →](https://vuejs.org/api/reactivity-advanced#shallowref)27:::2829## Type Declarations3031```ts32export type RefAutoResetReturn<T = any> = Ref<T>33/**34* Create a ref which will be reset to the default value after some time.35*36* @see https://vueuse.org/refAutoReset37* @param defaultValue The value which will be set.38* @param afterMs A zero-or-greater delay in milliseconds.39*/40export declare function refAutoReset<T>(41defaultValue: MaybeRefOrGetter<T>,42afterMs?: MaybeRefOrGetter<number>,43): RefAutoResetReturn<T>44/** @deprecated use `refAutoReset` instead */45export declare const autoResetRef: typeof refAutoReset46```47