An open API service indexing awesome lists of open source software.

https://github.com/salman-ahamed/debounce

Searching with debounce is a technique used to optimize search functionality in web applications. It helps reduce the number of search requests made to the server by delaying the execution of the search function until a certain amount of time has passed since the user stopped typing.
https://github.com/salman-ahamed/debounce

javascript js ractjs react search-with-debounce ts typescript

Last synced: about 1 month ago
JSON representation

Searching with debounce is a technique used to optimize search functionality in web applications. It helps reduce the number of search requests made to the server by delaying the execution of the search function until a certain amount of time has passed since the user stopped typing.

Awesome Lists containing this project

README

          

Search with Debounce

### Functionality

```ts
const filterBySearch = (value: string) => {
console.log(value);
};

const debounce = (fn: (value: string) => void, delay: number) => {
let timeoutId: NodeJS.Timeout | number | undefined;

return (e: FormEvent) => {
if (timeoutId) {
clearTimeout(timeoutId);
}

timeoutId = setTimeout(() => {
fn((e.target as HTMLInputElement).value);
}, delay);
};
};
```

### Input Section

```tsx
filterBySearch(value), 500)}
/>
```