From 599d43ac037513b1ece354762856421e5d508dc1 Mon Sep 17 00:00:00 2001 From: Allan Lasser Date: Tue, 20 Feb 2024 13:48:58 -0500 Subject: [PATCH] Debounce query changes --- src/common/SearchInput.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/common/SearchInput.svelte b/src/common/SearchInput.svelte index 3f655646a..dfbb7570b 100644 --- a/src/common/SearchInput.svelte +++ b/src/common/SearchInput.svelte @@ -3,6 +3,15 @@ import { writable } from "svelte/store"; export const query = writable(""); + + let timer; + let delay = 100; + const debounce = (v, fn) => { + clearTimeout(timer); + timer = setTimeout(() => { + fn(v); + }, delay); + };