dioxus/packages/desktop/examples/stress.rs

24 lines
456 B
Rust
Raw Normal View History

2023-10-17 19:45:37 +00:00
use dioxus::prelude::*;
2024-01-31 02:42:36 +00:00
fn main() {
launch_desktop(app);
}
fn app() -> Element {
let mut state = use_signal(|| 0);
use_future(move || async move {
loop {
state += 1;
tokio::time::sleep(std::time::Duration::from_millis(1)).await;
2023-10-17 19:45:37 +00:00
}
});
2024-01-14 05:12:21 +00:00
rsx! {
2024-01-31 02:42:36 +00:00
button { onclick: move |_| state.set(0), "reset" }
2023-10-17 19:45:37 +00:00
for _ in 0..10000 {
2024-01-31 02:42:36 +00:00
div { "hello desktop! {state}" }
2023-10-17 19:45:37 +00:00
}
2024-01-14 05:12:21 +00:00
}
2023-10-17 19:45:37 +00:00
}