Skip to content

Commit

Permalink
Debounce query changes
Browse files Browse the repository at this point in the history
Some more work on debouncing search query

Extend delay
  • Loading branch information
allanlasser committed Feb 20, 2024
1 parent 255ca6d commit 1c7ee2c
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/common/SearchInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,30 @@
export const query = writable("");
</script>

<script>
<script lang="ts">
import Search from "./icons/Search.svelte";
export let delay = 250;
let value = $query;
let timer;
const debounce = (v, fn) => {
clearTimeout(timer);
timer = setTimeout(() => {
fn(v);
}, delay);
};
$: {
debounce(value, query.set);
}
</script>

<label class="search">
<Search size={0.8} />
<input
type="search"
bind:value={$query}
bind:value
aria-label="Search Add-Ons"
placeholder={$_("addonBrowserDialog.searchPlaceholder")}
/>
Expand Down

0 comments on commit 1c7ee2c

Please sign in to comment.