-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
index.ts
24 lines (22 loc) · 891 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import type { MaybeRefOrGetter } from '@vueuse/shared'
import { debounceFilter } from '@vueuse/shared'
import type { Ref } from 'vue-demi'
import type { UseRefHistoryOptions, UseRefHistoryReturn } from '../useRefHistory'
import { useRefHistory } from '../useRefHistory'
/**
* Shorthand for [useRefHistory](https://vueuse.org/useRefHistory) with debounce filter.
*
* @see https://vueuse.org/useDebouncedRefHistory
* @param source
* @param options
*/
export function useDebouncedRefHistory<Raw, Serialized = Raw>(
source: Ref<Raw>,
options: Omit<UseRefHistoryOptions<Raw, Serialized>, 'eventFilter'> & { debounce?: MaybeRefOrGetter<number> } = {},
): UseRefHistoryReturn<Raw, Serialized> {
const filter = options.debounce ? debounceFilter(options.debounce) : undefined
const history = useRefHistory(source, { ...options, eventFilter: filter })
return {
...history,
}
}