Move router into app, and out of util

This commit is contained in:
Jon Staab
2024-09-03 13:31:13 -07:00
parent 7b2233f8db
commit 6ee79eb219
12 changed files with 456 additions and 136 deletions
+14
View File
@@ -430,6 +430,20 @@ export const memoize = <T>(f: (...args: any[]) => T) => {
}
}
export const throttleWithValue = <T>(ms: number, f: () => T) => {
let value: T
const update = throttle(ms, () => {
value = f()
})
return () => {
update()
return value
}
}
export const batch = <T>(t: number, f: (xs: T[]) => void) => {
const xs: T[] = []
const cb = throttle(t, () => xs.length > 0 && f(xs.splice(0)))