use_interval
Reactive counter increases on every interval.
Demo
Usage
use leptos::prelude::*;
use leptos_use_interval::{use_interval, UseIntervalReturn};
#[component]
fn Demo() -> impl IntoView {
let UseIntervalReturn {
counter,
reset,
is_active,
pause,
resume
} = use_interval( 200 );
view! { }
}
SendWrapped Return
The returned closures pause, resume and reset are sendwrapped functions. They can
only be called from the same thread that called use_intersection_observer.
Server-Side Rendering
Make sure you follow the instructions in Server-Side Rendering.
On the server this function will simply be ignored.
Installation
cargo add leptos-use-interval
Options
UseIntervalOptions
Options for use_interval_with_options
Every option is set with a builder method of the same name, e.g. UseIntervalOptions::default().immediate(...). See also the API docs.
immediate
Type: bool
Start the timer immediately. Defaults to true.
callback
Type: Rc<dyn Fn(u64)>
Callback on every interval.