clock.rs 441 B

123456789101112131415161718192021222324
  1. use dioxus::prelude::*;
  2. fn main() {
  3. launch_desktop(app);
  4. }
  5. fn app() -> Element {
  6. let mut count = use_signal(|| 0);
  7. use_future(|| async move {
  8. loop {
  9. tokio::time::sleep(std::time::Duration::from_millis(10)).await;
  10. count += 1;
  11. }
  12. });
  13. use_effect(move || {
  14. println!("High-Five counter: {}", count());
  15. });
  16. rsx! {
  17. div { "High-Five counter: {count}" }
  18. }
  19. }