debounce

Category Reactivity

Debounces the update of the value after a delay.

Demo

Search :

Usage

TIP

If you'd rather have them combined in one variable, check out debouncedState.

<script>
	import { debounce } from '@sv-use/core';
 
	let search = $state('');
	const debouncedSearch = debounce(() => search);
</script>
Type definitions
type DebounceOptions = {
    /**
     * The delay in milliseconds before updating the state.
     * @default 1000
     */
    delay?: number;
};
/**
 * Debounces the update of the value after a delay.
 * @param initial The reactive value as a getter.
 * @param options Additional options to customize the behavior.
 * @see https://svelte-librarian.github.io/sv-use/docs/core/reactivity/debounce
 */
export declare function debounce<T>(value: () => T, options?: DebounceOptions): {
    current: T | undefined;
};
export {};

Sources