@@ -4,27 +4,6 @@ import { readonly, ref, unref } from 'vue'
44import type { MaybeRef } from '../types'
55import type { DebouncerOptions } from '@tanstack/pacer'
66
7- export interface UseDebouncerReturn < TValue > {
8- /** The current debounced value */
9- value : Ref < TValue >
10- /** Set a new value (will be debounced) */
11- setValue : ( newValue : TValue ) => void
12- /** Force immediate update of the value */
13- flush : ( ) => void
14- /** Cancel any pending updates */
15- cancel : ( ) => void
16- /** Check if there are any pending updates */
17- isPending : Readonly < Ref < boolean > >
18- /** Get the number of times the value has been updated */
19- executionCount : Readonly < Ref < number > >
20- /** Update debouncer options */
21- setOptions : (
22- newOptions : Partial < DebouncerOptions < ( value : TValue ) => void > > ,
23- ) => void
24- /** Get current debouncer options */
25- getOptions : ( ) => Required < DebouncerOptions < ( value : TValue ) => void > >
26- }
27-
287/**
298 * Creates a debouncer instance with Vue reactivity integration.
309 * This composable provides a debounced value that updates only after
@@ -107,7 +86,26 @@ export interface UseDebouncerReturn<TValue> {
10786export function useDebouncer < TValue > (
10887 initialValue : MaybeRef < TValue > ,
10988 optionsInput : DebouncerOptions < ( value : TValue ) => void > ,
110- ) : UseDebouncerReturn < TValue > {
89+ ) : {
90+ /** The current debounced value */
91+ value : Ref < TValue >
92+ /** Set a new value (will be debounced) */
93+ setValue : ( newValue : TValue ) => void
94+ /** Force immediate update of the value */
95+ flush : ( ) => void
96+ /** Cancel any pending updates */
97+ cancel : ( ) => void
98+ /** Check if there are any pending updates */
99+ isPending : Readonly < Ref < boolean > >
100+ /** Get the number of times the value has been updated */
101+ executionCount : Readonly < Ref < number > >
102+ /** Update debouncer options */
103+ setOptions : (
104+ newOptions : Partial < DebouncerOptions < ( value : TValue ) => void > > ,
105+ ) => void
106+ /** Get current debouncer options */
107+ getOptions : ( ) => Required < DebouncerOptions < ( value : TValue ) => void > >
108+ } {
111109 const value = ref < TValue > ( unref ( initialValue ) ) as Ref < TValue >
112110 const _isPending = ref ( false )
113111 const _executionCount = ref ( 0 )
0 commit comments