stress.rs 641 B

1234567891011121314151617181920212223242526272829303132
  1. use dioxus::prelude::*;
  2. fn app(cx: Scope) -> Element {
  3. let state = use_state(cx, || 0);
  4. use_future(cx, (), |_| {
  5. to_owned![state];
  6. async move {
  7. loop {
  8. state += 1;
  9. tokio::time::sleep(std::time::Duration::from_millis(1)).await;
  10. }
  11. }
  12. });
  13. cx.render(rsx! {
  14. button {
  15. onclick: move |_| {
  16. state.set(0);
  17. },
  18. "reset"
  19. }
  20. for _ in 0..10000 {
  21. div {
  22. "hello desktop! {state}"
  23. }
  24. }
  25. })
  26. }
  27. fn main() {
  28. dioxus_desktop::launch(app);
  29. }