This commit is contained in:
zixu 2024-08-29 09:39:37 +08:00
parent c6567b8948
commit 6b49d15eae

View File

@ -49,13 +49,15 @@ function useThrottledMemo<T>(fn: () => T, delay: number): Accessor<T> {
createMemo(() => { createMemo(() => {
const value = fn(); const value = fn();
if (timeoutId === null) { if (timeoutId === null) {
// @ts-expect-error
setThrottledValue(value); setThrottledValue(value);
timeoutId = setTimeout(() => { timeoutId = setTimeout(() => {
timeoutId = null; timeoutId = null;
// @ts-expect-error
setThrottledValue(fn()); setThrottledValue(fn());
}, delay); }, delay);
} }
}); });
return throttledValue; return throttledValue;
} }