Function leptos_use::use_idle
source · pub fn use_idle(timeout: u64) -> UseIdleReturn<impl Fn() + Clone>
Expand description
§Demo
§Usage
let UseIdleReturn {
idle, last_active, ..
} = use_idle(5 * 60 * 1000); // 5 minutes
log!("{}", idle.get()); // true or false
Programatically resetting:
use leptos::*;
let UseIdleReturn {
idle, last_active, reset
} = use_idle(5 * 60 * 1000); // 5 minutes
reset(); // restarts the idle timer. Does not change the `last_active` value.
§Server-Side Rendering
On the server this will always return static signals
ⓘ
UseIdleReturn{
idle: Signal(initial_state),
last_active: Signal(now),
reset: || {}
}