create Signal::global

This commit is contained in:
Evan Almloff committed 2024-01-19 13:46:17 -06:00
1 parent 3dce650367
commit bc914deeaa
23 files changed
+324 -1105

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
//! Example: README.md showcase
//!
//! The example from the README.md.
use dioxus::prelude::*;
static COUNT: GlobalSignal<i32> = Signal::global(|| 0);
fn main() {
launch_desktop(app);
}
fn app() -> Element {
rsx! {
h1 { "High-Five counter: {COUNT}" }
button { onclick: move |_| *COUNT.write() += 1, "Up high!" }
button { onclick: move |_| *COUNT.write() -= 1, "Down low!" }
}
}