Skip to content

refAutoReset

Category
Export Size
236 B
Last Changed
last month
Alias
autoResetRef

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

Demo

Default message

Usage

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

INFO

You can use triggerRef to trigger effects after making deep mutations to the inner value of a refAutoReset.

Type Declarations

ts
export type 
RefAutoResetReturn
<
T
= any> =
Ref
<
T
>
/** * Create a ref which will be reset to the default value after some time. * * @see https://vueuse.org/refAutoReset * @param defaultValue The value which will be set. * @param afterMs A zero-or-greater delay in milliseconds. */ export declare function
refAutoReset
<
T
>(
defaultValue
:
MaybeRefOrGetter
<
T
>,
afterMs
?:
MaybeRefOrGetter
<number>,
):
RefAutoResetReturn
<
T
>
/** @deprecated use `refAutoReset` instead */ export declare const
autoResetRef
: typeof
refAutoReset

Source

SourceDemoDocs

Contributors

Anthony Fu
Anthony Fu
IlyaL
NoiseFan
Vida Xie
IlyaL
Robin
OrbisK
moander
sun0day
wheat
Kasper Seweryn

Changelog

v14.0.0-alpha.2 on
e5f74 - feat!: deprecate alias exports in favor of original function names (#5009)
v13.4.0 on
319d8 - feat(shared): Introduce TimerHandle for setTimeout type (#4801)
v13.1.0 on
c1d6e - feat(shared): ensure return types exists (#4659)
v12.8.0 on
7432f - feat(types): deprecate MaybeRef and MaybeRefOrGetter in favor of Vue's native (#4636)
v12.3.0 on
59f75 - feat(toValue): deprecate toValue from @vueuse/shared in favor of Vue's native
v12.0.0-beta.1 on
0a9ed - feat!: drop Vue 2 support, optimize bundles and clean up (#4349)
v10.4.0 on
71685 - feat: support maybe-ref as value (#3342)

Released under the MIT License.

Build smarter with AI
Join a free workshop to explore LLMs and advanced AI tools.
Register now
October 22