dioxus/examples/tasks.rs
2021-12-26 14:22:30 -05:00

29 lines
587 B
Rust

//! Example: README.md showcase
//!
//! The example from the README.md.
use std::time::Duration;
use dioxus::prelude::*;
fn main() {
dioxus::desktop::launch(app);
}
fn app(cx: Scope<()>) -> Element {
let mut count = use_state(&cx, || 0);
cx.push_future(|| async move {
tokio::time::sleep(Duration::from_millis(100)).await;
count += 1;
});
cx.render(rsx! {
div {
h1 { "High-Five counter: {count}" }
button {
onclick: move |_| count +=1 ,
"Click me!"
}
}
})
}