Skip to content
On this page

autoResetRef

Category
Last Changed
a month ago

A ref which will be reset to the default value after some time.

Demo

source

default message

Usage

import { autoResetRef } from '@vueuse/core'

const message = autoResetRef('default message', 1000)

const setMessage = () => {
  // here the value will change to 'message has set' but after 1000ms, it will change to 'default message'
  message.value = 'message has set'
}
import { autoResetRef } from '@vueuse/core'

const message = autoResetRef('default message', 1000)

const setMessage = () => {
  // here the value will change to 'message has set' but after 1000ms, it will change to 'default message'
  message.value = 'message has set'
}

Type Declarations

/**
 * Create a ref which will be reset to the default value after some time.
 *
 * @see https://vueuse.org/autoResetRef
 * @param defaultValue The value which will be set.
 * @param afterMs      A zero-or-greater delay in milliseconds.
 */
export declare function autoResetRef<T>(
  defaultValue: T,
  afterMs?: MaybeRef<number>
): Ref<T>
/**
 * Create a ref which will be reset to the default value after some time.
 *
 * @see https://vueuse.org/autoResetRef
 * @param defaultValue The value which will be set.
 * @param afterMs      A zero-or-greater delay in milliseconds.
 */
export declare function autoResetRef<T>(
  defaultValue: T,
  afterMs?: MaybeRef<number>
): Ref<T>

Source

SourceDemoDocs

Contributors

Anthony Fu
Alex Kozack
翠 / green

Changelog

No recent changes
autoResetRef has loaded