dioxus/packages/fermi
2022-06-28 09:58:27 +07:00
..
src fermi: set atom value even it doesn't exist 2022-06-13 18:32:03 +08:00
Cargo.toml Release dioxus-core v0.2.1, dioxus-core-macro v0.2.1, dioxus-html v0.2.1, dioxus-interpreter-js v0.2.1, dioxus-desktop v0.2.3, dioxus-hooks v0.2.1, dioxus-liveview v0.1.0, dioxus-native-core v0.2.0, dioxus-native-core-macro v0.2.0, dioxus-router v0.2.3, dioxus-ssr v0.2.1, dioxus-tui v0.2.2, dioxus-web v0.2.1, fermi v0.2.1, dioxus v0.2.4 2022-05-02 23:57:20 -04:00
README.md tiny doc fix 2022-06-28 09:58:27 +07:00

Fermi ⚛

Atom-based global state management solution for Dioxus


Fermi is a global state management solution for Dioxus that's as easy as use_state.

Inspired by atom-based state management solutions, all state in Fermi starts as an atom:

static NAME: Atom<&str> = |_| "Dioxus";

From anywhere in our app, we can read our the value of our atom:

fn NameCard(cx: Scope) -> Element {      
    let name = use_read(&cx, NAME);
    cx.render(rsx!{ h1 { "Hello, {name}"} })
}

We can also set the value of our atom, also from anywhere in our app:

fn NameCard(cx: Scope) -> Element {      
    let set_name = use_set(&cx, NAME);
    cx.render(rsx!{
        button {
            onclick: move |_| set_name("Fermi"),
            "Set name to fermi"
        }
    })
}

It's that simple!

Installation

Fermi is currently under construction, so you have to use the master branch to get started.

[dependencies]
fermi = { git = "https://github.com/dioxuslabs/fermi" }

Running examples

The examples here use Dioxus Desktop to showcase their functionality. To run an example, use

$ cargo run --example EXAMPLE

Features

Broadly our feature set to required to be released includes:

  • Support for Atoms
  • Support for AtomRef (for values that aren't clone)
  • Support for Atom Families
  • Support for memoized Selectors
  • Support for memoized SelectorFamilies
  • Support for UseFermiCallback for access to fermi from async