use_interval_fn
Wrapper for set_interval with controls.
Demo
Usage
use leptos::prelude::*;
use leptos_use_interval_fn::use_interval_fn;
use leptos_use_filters::Pausable;
#[component]
fn Demo() -> impl IntoView {
let Pausable { pause, resume, is_active } = use_interval_fn(
|| {
// do something
},
1000,
);
view! { }
}
SendWrapped Return
The returned closures pause and resume are sendwrapped functions. They can
only be called from the same thread that called use_interval_fn.
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-fn
Options
UseIntervalFnOptions
Options for use_interval_fn_with_options
Every option is set with a builder method of the same name, e.g. UseIntervalFnOptions::default().immediate(...). See also the API docs.
immediate
Type: bool
Start the timer immediately. Defaults to true.
immediate_callback
Type: bool
Execute the callback immediate after calling this function. Defaults to false