@empathyco/x-components
Version:
Empathy X Components
29 lines (17 loc) • 1.16 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [@empathyco/x-components](./x-components.md) > [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
| Parameter | Type | Description |
| --- | --- | --- |
| fn | (...args: Params) => void | Function to be debounced. |
| debounceTimeInMs | number | Time of debounce in ms. |
| debounceOptions | [DebounceOptions](./x-components.debounceoptions.md) | _(Optional)_ The options for the debounce strategy. |
**Returns:**
import("../utils/types").[DebouncedFunction](./x-components.debouncedfunction.md)<!-- --><Params>
Debounced function obtained from `fn` parameter.