mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-16 05:38:26 +00:00
24 lines
522 B
Rust
24 lines
522 B
Rust
use dioxus::prelude::*;
|
|
use std::time::Duration;
|
|
|
|
fn main() {
|
|
dioxus::desktop::launch_with_props(with_hot_reload, app, |b| b);
|
|
}
|
|
|
|
fn app(cx: Scope) -> Element {
|
|
let count = use_state(&cx, || 0);
|
|
|
|
use_future(&cx, (), move |_| {
|
|
let mut count = count.clone();
|
|
async move {
|
|
loop {
|
|
tokio::time::sleep(Duration::from_millis(10)).await;
|
|
count += 1;
|
|
}
|
|
}
|
|
});
|
|
|
|
cx.render(rsx! {
|
|
h1 { "High-Five counter: {count}" }
|
|
})
|
|
}
|