Function leptos_use::signal_throttled

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

Throttle changing of a Signal value.

§Demo

Link to Demo

§Usage

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

§Options

The usual throttle options leading and trailing are available.

let (input, set_input) = create_signal("");
let throttled: Signal<&'static str> = signal_throttled_with_options(
    input,
    1000.0,
    ThrottleOptions::default().leading(false).trailing(true)
);

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