mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-14 00:17:17 +00:00
20 lines
491 B
Rust
20 lines
491 B
Rust
//! Example: README.md showcase
|
|
//!
|
|
//! The example from the README.md.
|
|
|
|
use dioxus::prelude::*;
|
|
|
|
fn main() {
|
|
launch(app);
|
|
}
|
|
|
|
static COUNT: GlobalSignal<i32> = Signal::global(|| 0);
|
|
static DOUBLED_COUNT: GlobalMemo<i32> = Signal::global_memo(|| COUNT() * 2);
|
|
|
|
fn app() -> Element {
|
|
rsx! {
|
|
h1 { "{COUNT} x 2 = {DOUBLED_COUNT}" }
|
|
button { onclick: move |_| *COUNT.write() += 1, "Up high!" }
|
|
button { onclick: move |_| *COUNT.write() -= 1, "Down low!" }
|
|
}
|
|
}
|