clock.rs 540 B

1234567891011121314151617181920212223242526
  1. //! Example: README.md showcase
  2. //!
  3. //! The example from the README.md.
  4. use dioxus::prelude::*;
  5. use dioxus_signals::use_signal;
  6. fn main() {
  7. dioxus_desktop::launch(app);
  8. }
  9. fn app(cx: Scope) -> Element {
  10. let mut count = use_signal(cx, || 0);
  11. use_future!(cx, || async move {
  12. loop {
  13. tokio::time::sleep(std::time::Duration::from_millis(100)).await;
  14. count += 1;
  15. println!("current: {count}");
  16. }
  17. });
  18. cx.render(rsx! {
  19. div { "High-Five counter: {count}" }
  20. })
  21. }