remove unused debouncer class
Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
This commit is contained in:
@@ -84,36 +84,6 @@ export function onReady(callback: () => void, ...components: TesoftComponent[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Debouncer<T extends any[]> {
|
|
||||||
private timer: number | null;
|
|
||||||
private readonly apply: (...args: T) => void;
|
|
||||||
|
|
||||||
constructor(apply: (...args: T) => void, timeoutMs: number = 300) {
|
|
||||||
this.timer = null;
|
|
||||||
this.apply = (...args: T) => {
|
|
||||||
if (this.timer !== null) {
|
|
||||||
clearTimeout(this.timer);
|
|
||||||
this.timer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.timer = setTimeout(() => {
|
|
||||||
apply(...args);
|
|
||||||
}, timeoutMs);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
run(...args: T) {
|
|
||||||
this.apply(...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
stop() {
|
|
||||||
if (this.timer !== null) {
|
|
||||||
clearTimeout(this.timer);
|
|
||||||
this.timer = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function sendApiPost(path: string, data: Record<string, any>): Promise<Response> {
|
export function sendApiPost(path: string, data: Record<string, any>): Promise<Response> {
|
||||||
const url = new URL(`/api/${path}`, location.origin);
|
const url = new URL(`/api/${path}`, location.origin);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user