From c318c4cedf3f50c21c403649945c2abbbc30a89e Mon Sep 17 00:00:00 2001 From: Terry Truong Date: Sat, 21 Jan 2023 15:23:51 +1100 Subject: Do more minor refactoring Document some variables coupled between client and server. Add more term consistency ('unit', 'event density'). Make console messages more consistent. --- src/util.ts | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/util.ts') 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, delay: number){ let timeout = 0; @@ -51,6 +52,7 @@ export function makeThrottledAsync(hdlr: (...args: any[]) => Promise, 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 -- cgit v1.2.3