2024-02-14 21:48:58 +00:00
|
|
|
//! The example from the readme!
|
|
|
|
//!
|
|
|
|
//! This example demonstrates how to create a simple counter app with dioxus. The `Signal` type wraps inner values,
|
2024-03-11 14:49:26 +00:00
|
|
|
//! making them `Copy`, allowing them to be freely used in closures and async functions. `Signal` also provides
|
2024-02-14 21:48:58 +00:00
|
|
|
//! helper methods like AddAssign, SubAssign, toggle, etc, to make it easy to update the value without running
|
|
|
|
//! into lock issues.
|
|
|
|
|
2021-07-07 17:51:55 +00:00
|
|
|
use dioxus::prelude::*;
|
2021-12-30 02:28:28 +00:00
|
|
|
|
2021-07-06 16:13:00 +00:00
|
|
|
fn main() {
|
2024-10-10 23:00:58 +00:00
|
|
|
dioxus::launch(app);
|
2021-07-06 16:13:00 +00:00
|
|
|
}
|
|
|
|
|
2024-01-14 04:51:37 +00:00
|
|
|
fn app() -> Element {
|
2024-01-14 05:12:21 +00:00
|
|
|
let mut count = use_signal(|| 0);
|
2021-07-06 16:13:00 +00:00
|
|
|
|
2024-01-16 19:18:46 +00:00
|
|
|
rsx! {
|
2024-02-01 09:05:28 +00:00
|
|
|
h1 { "High-Five counter: {count}" }
|
2022-03-05 22:07:34 +00:00
|
|
|
button { onclick: move |_| count += 1, "Up high!" }
|
|
|
|
button { onclick: move |_| count -= 1, "Down low!" }
|
2024-01-14 05:12:21 +00:00
|
|
|
}
|
2022-01-02 23:35:38 +00:00
|
|
|
}
|