evcc-io/assets/js/utils/debounce.ts
Thomas Speer 5617c19bb9
UI: make loadpoints sortable and hideable (#23621)
Co-authored-by: Michael Geers <michael@geers.tv>
2025-09-29 13:05:29 +02:00

9 lines
286 B
TypeScript

import type { Timeout } from "@/types/evcc";
export function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): T {
let timer: Timeout;
return ((...args: any[]) => {
if (timer) clearTimeout(timer);
timer = setTimeout(() => fn(...args), delay);
}) as T;
}