aboutsummaryrefslogtreecommitdiff
path: root/src/util.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.ts')
-rw-r--r--src/util.ts2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/util.ts b/src/util.ts
index bb0d162..ea9e76e 100644
--- a/src/util.ts
+++ b/src/util.ts
@@ -43,6 +43,7 @@ export function makeThrottled(hdlr: (...args: any[]) => void, delay: number){
timeout = window.setTimeout(async () => hdlr(...args), delay);
};
}
+
// Like makeThrottled(), but accepts an async function
export function makeThrottledAsync(hdlr: (...args: any[]) => Promise<void>, delay: number){
let timeout = 0;
@@ -51,6 +52,7 @@ export function makeThrottledAsync(hdlr: (...args: any[]) => Promise<void>, dela
timeout = window.setTimeout(async () => await hdlr(...args), delay);
};
}
+
// Like makeThrottled(), but, for runs of fast handler calls, calls it at spaced intervals, and at the start/end
export function makeThrottledSpaced(hdlr: (...args: any[]) => void, delay: number){
let lastHdlrTime = 0; // Used for throttling