#dioxus #state #redux #api-bindings #mobx

macro modx

A way to handle states with structs in Dioxus inspired by mobx

5 releases

0.1.2 May 12, 2024
0.1.1 Apr 28, 2024
0.1.0 Apr 19, 2024
0.0.1 Apr 11, 2024

#398 in WebAssembly

Download history 11/week @ 2024-07-24 6/week @ 2024-07-31 17/week @ 2024-09-18 27/week @ 2024-09-25

257 downloads per month

GPL-3.0-or-later

50KB
299 lines

modx

github release crates.io downloads docs.rs docs stars

modx is an experimental way to handle states with structs in Dioxus inspired by mobx.

Example

#[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

Documentation can be found at https://docs.rs/modx

More examples

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)

Development progress

In the near future, most of the hooks should be rewrote to work with modx.

Here is the current status:

  • Signals
  • Props
  • Resources
  • Memo
  • Server future

Dependencies

~225–670KB
~16K SLoC