Skip to content

refDebounced

Category
Last Changed
5 months ago
Alias
useDebouncedebouncedRef

Debounce execution of a ref value.

Demo

Delay is set to 1000ms for this demo.

Debounced:

Times Updated: 0

Usage




 



















import { refDebounced } from '@vueuse/core'

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

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

await sleep(1100)

console.log(debounced.value) // 'bar'
import { refDebounced } from '@vueuse/core'

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

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

await sleep(1100)

console.log(debounced.value) // 'bar'

You can also pass an optional 3rd parameter including maxWait option. See useDebounceFnfor details.

Type Declarations

/**
 * Debounce updates of a ref.
 *
 * @return A new debounced ref.
 */
export declare function refDebounced<T>(
  value: Ref<T>,
  ms?: number,
  options?: DebounceFilterOptions
): Readonly<Ref<T>>
export { refDebounced as useDebounce, refDebounced as debouncedRef }
/**
 * Debounce updates of a ref.
 *
 * @return A new debounced ref.
 */
export declare function refDebounced<T>(
  value: Ref<T>,
  ms?: number,
  options?: DebounceFilterOptions
): Readonly<Ref<T>>
export { refDebounced as useDebounce, refDebounced as debouncedRef }

Source

SourceDemoDocs

Contributors

Anthony Fu

Changelog

No recent changes
refDebounced has loaded