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(() => {
const value = fn();
if (timeoutId === null) {
// @ts-expect-error
setThrottledValue(value);
timeoutId = setTimeout(() => {
timeoutId = null;
// @ts-expect-error
setThrottledValue(fn());
}, delay);
}
});
return throttledValue;
}
}