From ce3dcad346d54f4ec676e1d0d230b2b0126f38cf Mon Sep 17 00:00:00 2001 From: Dominik Klein Date: Tue, 25 Oct 2022 07:33:33 +0200 Subject: [PATCH] feat(refDebounced): use MaybeComputedRef for ms (#2337) --- packages/shared/refDebounced/index.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/shared/refDebounced/index.ts b/packages/shared/refDebounced/index.ts index 1faa4d1be30..4050edb89cf 100644 --- a/packages/shared/refDebounced/index.ts +++ b/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(value: Ref, ms = 200, options: DebounceFilterOptions = {}): Readonly> { - if (ms <= 0) - return value - +export function refDebounced(value: Ref, ms: MaybeComputedRef = 200, options: DebounceFilterOptions = {}): Readonly> { const debounced = ref(value.value as T) as Ref const updater = useDebounceFn(() => {