dioxus/packages/desktop/examples/stress.rs

29 lines
568 B
Rust
Raw Normal View History

2023-10-17 19:45:37 +00:00
use dioxus::prelude::*;
fn app() -> Element {
let mut state = use_signal(|| 0);
use_future(|| 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! {
2023-10-17 19:45:37 +00:00
button {
onclick: move |_| state.set(0),
2023-10-17 19:45:37 +00:00
"reset"
}
for _ in 0..10000 {
div {
"hello desktop! {state}"
}
}
2024-01-14 05:12:21 +00:00
}
2023-10-17 19:45:37 +00:00
}
fn main() {
2024-01-20 00:36:40 +00:00
dioxus::desktop::launch::launch(app, Default::default(), Default::default());
2023-10-17 19:45:37 +00:00
}