use_timestamp
Reactive current timestamp.
Demo
Usage
use leptos::prelude::*;
use leptos_use::use_timestamp;
#[component]
fn Demo() -> impl IntoView {
let timestamp = use_timestamp();
view! { }
}
With controls:
use leptos::prelude::*;
use leptos_use::{use_timestamp_with_controls, UseTimestampReturn};
#[component]
fn Demo() -> impl IntoView {
let UseTimestampReturn {
timestamp,
is_active,
pause,
resume,
} = use_timestamp_with_controls();
view! { }
}
SendWrapped Return
The returned closures pause
and resume
of the ..._with_controls
versions are
sendwrapped functions. They can only be called from the same thread that called
use_timestamp_with_controls
.
Server-Side Rendering
On the server this function will return a signal with the milliseconds since the Unix epoch.
But the signal will never update (as there's no request_animation_frame
on the server).
Feature
This function is only available if the crate feature
use_timestamp
is enabled