dioxus-sdk-time

Crates.iodioxus-sdk-time
lib.rsdioxus-sdk-time
version0.7.0
created_at2025-11-06 21:45:05.538119+00
updated_at2025-11-06 21:45:05.538119+00
descriptionTiming utilities and hooks for Dioxus.
homepagehttps://dioxuslabs.com
repositoryhttps://github.com/DioxusLabs/sdk/
max_upload_size
id1920766
size69,121
Jonathan Kelley (jkelleyrtp)

documentation

README

Dioxus Time

Timing utilities and hooks for Dioxus.

Features:

  • Intervals
  • Debounces
  • Timeouts

Usage

Add dioxus-sdk-time to your Cargo.toml:

[dependencies]
dioxus-sdk-time = "0.1"

Example:

use dioxus::{logger::tracing::info, prelude::*};
use dioxus_sdk_time::{use_debounce, use_interval};
use std::time::Duration;

fn main() {
    dioxus::launch(App);
}

#[component]
fn App() -> Element {
    let mut count = use_signal(|| 0);

    // Increment count every second.
    use_interval(Duration::from_secs(1), move || count += 1);

    // Reset count after 2 seconds of the latest action call.
    let mut debounce = use_debounce(Duration::from_millis(2000), move |text| {
        info!("{text}");
        count.set(0);
    });

    rsx! {
        p { "{count}" },
        button {
            // Trigger the debounce.
            onclick: move |_| debounce.action("button was clicked"),
            "Reset the counter! (2 second debounce)"
        }
    }
}

Commit count: 119

cargo fmt