dioxus/examples/clock.rs

23 lines
467 B
Rust
Raw Normal View History

use dioxus::prelude::*;
2023-08-08 20:31:38 +00:00
use dioxus_signals::use_signal;
2022-12-30 01:39:22 +00:00
fn main() {
dioxus_desktop::launch(app);
}
fn app(cx: Scope) -> Element {
2023-08-08 20:31:38 +00:00
let mut count = use_signal(cx, || 0);
2023-08-05 00:23:57 +00:00
2023-08-05 00:25:40 +00:00
use_future!(cx, || async move {
loop {
2023-08-08 20:31:38 +00:00
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
count += 1;
println!("current: {count}");
2023-08-05 00:25:40 +00:00
}
});
2023-08-05 00:23:57 +00:00
2023-08-08 20:31:38 +00:00
cx.render(rsx! {
div { "High-Five counter: {count}" }
})
}