feat: debounced main page search and rolled back to old input component

This commit is contained in:
Akhil Mohan
2024-05-06 20:43:23 +05:30
parent b4f1bec1a9
commit 79e9b1b2ae
4 changed files with 28 additions and 36 deletions
+15
View File
@@ -0,0 +1,15 @@
export const debounce = <F extends (...args: any[]) => any>(
func: F,
delay: number
): ((...args: Parameters<F>) => void) => {
let timeoutId: ReturnType<typeof setTimeout> | null;
return function debounced(...args: Parameters<F>) {
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
func(...args);
timeoutId = null;
}, delay);
};
};