Leptos-Use Guide

use_timeout_fn

Wrapper for setTimeout with controls.

Demo

Usage

use leptos::*;
use leptos_use::{use_timeout_fn, UseTimeoutFnReturn};

#[component]
fn Demo() -> impl IntoView {
let UseTimeoutFnReturn { start, stop, is_pending, .. } = use_timeout_fn(
    |i: i32| {
        // do sth
    },
    3000.0
);

start(3);

view! { }
}

Server-Side Rendering

On the server the callback will never be run. The returned functions are all no-ops and is_pending will always be false.

Feature

This function is only available if the crate feature use_timeout_fn is enabled

Types

Source

SourceDemoDocs