Delay is set to 1000ms for this demo.

Debounced:

Times Updated: 0

useDebounce

Debounce execution of a ref value.

Usage




 








import { useDebounce } from '@vueuse/core'

const input = ref('foo')
const debounced = useDebounce(input, 1000)

input.value = 'bar'
console.log(debounced.value) // 'foo'

await sleep(1100)

console.log(debounced.value) // 'bar'
  • useThrottle
  • useThrottleFn
  • useDebounce
  • useDebounceFn

Type Declarations

export declare function useDebounce<T>(
  value: Ref<T>,
  ms?: number
): Readonly<Ref<T>>

Source

SourceDemoDocs