Crates.io | modx |
lib.rs | modx |
version | 0.1.2 |
source | src |
created_at | 2024-04-11 22:28:09.863412 |
updated_at | 2024-05-12 20:02:38.182325 |
description | A way to handle states with structs in Dioxus inspired by mobx |
homepage | |
repository | https://github.com/tkr-sh/modx |
max_upload_size | |
id | 1205538 |
size | 184,606 |
modx is an experimental way to handle states with structs in Dioxus inspired by mobx.
#[modx::store]
struct CounterStore {
count: i64,
}
impl CounterStore {
fn inc(&mut self) {
self.count += 1;
}
fn dec(&mut self) {
self.count -= 1;
}
}
fn app() -> Element {
let mut store = CounterStore::new();
rsx! {
button { onclick: move |_| store.inc(), "+1" }
button { onclick: move |_| store.dec(), "-1" }
"{store.count}"
}
}
Documentation can be found at https://docs.rs/modx
There are some examples at ~/examples
so you can see how to use modx
and how it behaves.
You can run an example with:
cargo run --example this_example
with this_example
being the name of the file (without the extension)
In the near future, most of the hooks should be rewrote to work with modx.
Here is the current status: