The use directive for debounce.
npm i svelte-use-debounce
<script>
import {debounce} from "svelte-use-debounce";
</script>
<input use-debounce={{ms: 300, callback: (value) => { ... }}} />
<script lang="ts">
import {debounce, type DebounceOptions} from "svelte-use-debounce";
const opts: DebounceOptions = {
ms: 300,
callback: (value: string) => {...}
};
</script>
<input use-debounce={opts} />
Option | Type | Description |
---|---|---|
ms? | Number | Sets the debounce time. |
callback | (str: string) => void; | Callback to run when it debounces |