dioxus/packages/dioxus-tui/examples/task.rs

29 lines
731 B
Rust
Raw Normal View History

2022-01-01 14:49:08 +00:00
use dioxus::prelude::*;
fn main() {
dioxus_tui::launch(app);
2022-01-01 14:49:08 +00:00
}
fn app() -> Element {
let mut count = use_signal(|| 0);
2022-01-01 14:49:08 +00:00
use_future(move || async move {
loop {
count += 1;
tokio::time::sleep(std::time::Duration::from_millis(1000)).await;
schedule_update();
2022-01-01 14:49:08 +00:00
}
});
2024-01-14 05:12:21 +00:00
rsx! {
2022-01-01 14:49:08 +00:00
div { width: "100%",
div { width: "50%", height: "5px", background_color: "blue", justify_content: "center", align_items: "center",
"Hello {count}!"
}
div { width: "50%", height: "10px", background_color: "red", justify_content: "center", align_items: "center",
"Hello {count}!"
}
}
2024-01-14 05:12:21 +00:00
}
2022-01-01 14:49:08 +00:00
}