mirror of
https://github.com/pocket-id/pocket-id.git
synced 2025-12-17 01:11:38 +03:00
initial commit
This commit is contained in:
13
frontend/src/lib/utils/debounce-util.ts
Normal file
13
frontend/src/lib/utils/debounce-util.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function debounced<T extends (...args: any[]) => void>(func: T, delay: number) {
|
||||
let debounceTimeout: number | undefined;
|
||||
|
||||
return (...args: Parameters<T>) => {
|
||||
if (debounceTimeout !== undefined) {
|
||||
clearTimeout(debounceTimeout);
|
||||
}
|
||||
|
||||
debounceTimeout = setTimeout(() => {
|
||||
func(...args);
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user