UNPKG

@empathyco/x-components

Version:
89 lines (41 loc) 1.4 kB
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [useDebounce](./x-components.usedebounce.md) ## useDebounce() function Composable which wraps the function passed as parameter into a debounced function and returns it. It also cancels the debounced function when component is unmounted. **Signature:** ```typescript export declare function useDebounce<Params extends any[]>(fn: (...args: Params) => void, debounceTimeInMs: number, debounceOptions?: DebounceOptions): import("../utils/types").DebouncedFunction<Params>; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> fn </td><td> (...args: Params) =&gt; void </td><td> Function to be debounced. </td></tr> <tr><td> debounceTimeInMs </td><td> number </td><td> Time of debounce in ms. </td></tr> <tr><td> debounceOptions </td><td> [DebounceOptions](./x-components.debounceoptions.md) </td><td> _(Optional)_ The options for the debounce strategy. </td></tr> </tbody></table> **Returns:** import("../utils/types").[DebouncedFunction](./x-components.debouncedfunction.md)<!-- -->&lt;Params&gt; Debounced function obtained from `fn` parameter.