Skip to content

Commit f48759c

Browse files
committed
debounce doesn't update in templates after initial debounce
1 parent d95589f commit f48759c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

reactiveweb/src/debounce.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,16 @@ class TrackedValue<T> {
6060
*/
6161
export function debounce<Value = unknown>(ms: number, thunk: () => Value) {
6262
let lastValue: Value;
63-
let timer: number;
6463
let state = new TrackedValue<Value>();
6564

6665
return resource(({ on }) => {
66+
let timer: number;
67+
6768
lastValue = thunk();
6869

6970
on.cleanup(() => timer && clearTimeout(timer));
7071
timer = setTimeout(() => (state.value = lastValue), ms);
7172

72-
return state.value;
73+
return () => state.value;
7374
});
7475
}

0 commit comments

Comments
 (0)