1
0

tasks.rs 754 B

12345678910111213141516171819202122232425262728293031323334
  1. //! Example: README.md showcase
  2. //!
  3. //! The example from the README.md.
  4. use std::time::Duration;
  5. use dioxus::prelude::*;
  6. fn main() {
  7. dioxus::desktop::launch(App, |c| c);
  8. }
  9. static App: Component<()> = |cx, props| {
  10. let mut count = use_state(cx, || 0);
  11. cx.push_task(async move {
  12. tokio::time::sleep(Duration::from_millis(100)).await;
  13. println!("setting count");
  14. count += 1;
  15. // count.set(10);
  16. // *count += 1;
  17. // let c = count.get() + 1;
  18. // count.set(c);
  19. });
  20. cx.render(rsx! {
  21. div {
  22. h1 { "High-Five counter: {count}" }
  23. // button {
  24. // onclick: move |_| count +=1 ,
  25. // "Click me!"
  26. // }
  27. }
  28. })
  29. };