2022-12-30 00:53:43 +00:00
|
|
|
//! Example: README.md showcase
|
|
|
|
//!
|
|
|
|
//! The example from the README.md.
|
|
|
|
|
|
|
|
use dioxus::prelude::*;
|
2023-01-04 17:59:35 +00:00
|
|
|
use dioxus_signals::{use_init_signal_rt, use_signal};
|
2022-12-30 00:53:43 +00:00
|
|
|
|
2022-12-30 01:39:22 +00:00
|
|
|
fn main() {
|
|
|
|
dioxus_desktop::launch(app);
|
2022-12-30 00:53:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn app(cx: Scope) -> Element {
|
2023-01-04 17:59:35 +00:00
|
|
|
use_init_signal_rt(cx);
|
2022-12-30 00:53:43 +00:00
|
|
|
|
2023-01-04 17:59:35 +00:00
|
|
|
let mut count = use_signal(cx, || 0);
|
2022-12-30 00:53:43 +00:00
|
|
|
|
2023-01-04 17:59:35 +00:00
|
|
|
use_future!(cx, || async move {
|
|
|
|
loop {
|
|
|
|
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
|
|
|
|
count += 1;
|
2023-01-28 02:35:46 +00:00
|
|
|
println!("current: {count}");
|
2022-12-30 00:53:43 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
cx.render(rsx! {
|
|
|
|
div { "High-Five counter: {count}" }
|
|
|
|
})
|
|
|
|
}
|