global.rs 419 B

12345678910111213141516171819
  1. //! Example: README.md showcase
  2. //!
  3. //! The example from the README.md.
  4. use dioxus::prelude::*;
  5. static COUNT: GlobalSignal<i32> = Signal::global(|| 0);
  6. fn main() {
  7. launch_desktop(app);
  8. }
  9. fn app() -> Element {
  10. rsx! {
  11. h1 { "High-Five counter: {COUNT}" }
  12. button { onclick: move |_| *COUNT.write() += 1, "Up high!" }
  13. button { onclick: move |_| *COUNT.write() -= 1, "Down low!" }
  14. }
  15. }