leptos_use

Function signal_debounced

Source
pub fn signal_debounced<S, T>(
    value: S,
    ms: impl Into<MaybeSignal<f64>> + 'static,
) -> Signal<T>
where S: Into<Signal<T>>, T: Clone + 'static,
Expand description

Debounce changing of a Signal value.

§Demo

Link to Demo

§Usage

let (input, set_input) = create_signal("");
let debounced: Signal<&'static str> = signal_debounced(input, 1000.0);

§Options

The usual debounce option max_wait is available.

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))
);

§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.