Leptos-Use Guide

signal_debounced

Debounce changing of a Signal value.

Demo

Usage

use leptos::*;
use leptos_use::signal_debounced;

#[component]
fn Demo() -> impl IntoView {
let (input, set_input) = create_signal("");
let debounced: Signal<&'static str> = signal_debounced(input, 1000.0);

view! { }
}

Options

The usual debounce option max_wait is available.

use leptos::*;
use leptos_use::{signal_debounced_with_options, DebounceOptions};

#[component]
fn Demo() -> impl IntoView {
let (input, set_input) = create_signal("");
let debounced: Signal<&'static str> = signal_debounced_with_options(
    input,
    1000.0,
    DebounceOptions::default().max_wait(Some(500.0))
);

view! { }
}

Server-Side Rendering

Internally this uses setTimeout which is not supported on the server. So usually a throttled signal on the server will simply be ignored.

Source

SourceDemoDocs