Skip to content

Commit

Permalink
feat(refDebounced): use MaybeComputedRef for ms (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikklein committed Oct 25, 2022
1 parent d080b73 commit ce3dcad
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/shared/refDebounced/index.ts
@@ -1,17 +1,14 @@
import type { Ref } from 'vue-demi'
import { ref, watch } from 'vue-demi'
import { useDebounceFn } from '../useDebounceFn'
import type { DebounceFilterOptions } from '../utils'
import type { DebounceFilterOptions, MaybeComputedRef } from '../utils'

/**
* Debounce updates of a ref.
*
* @return A new debounced ref.
*/
export function refDebounced<T>(value: Ref<T>, ms = 200, options: DebounceFilterOptions = {}): Readonly<Ref<T>> {
if (ms <= 0)
return value

export function refDebounced<T>(value: Ref<T>, ms: MaybeComputedRef<number> = 200, options: DebounceFilterOptions = {}): Readonly<Ref<T>> {
const debounced = ref(value.value as T) as Ref<T>

const updater = useDebounceFn(() => {
Expand Down

0 comments on commit ce3dcad

Please sign in to comment.