2022-02-17 15:38:51 +00:00
|
|
|
|
|
|
|
<div align="center">
|
|
|
|
<h1>Fermi ⚛</h1>
|
|
|
|
<p>
|
|
|
|
<strong>Atom-based global state management solution for Dioxus</strong>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div align="center">
|
|
|
|
<!-- Crates version -->
|
|
|
|
<a href="https://crates.io/crates/dioxus">
|
|
|
|
<img src="https://img.shields.io/crates/v/dioxus.svg?style=flat-square"
|
|
|
|
alt="Crates.io version" />
|
|
|
|
</a>
|
|
|
|
<!-- Downloads -->
|
|
|
|
<a href="https://crates.io/crates/dioxus">
|
|
|
|
<img src="https://img.shields.io/crates/d/dioxus.svg?style=flat-square"
|
|
|
|
alt="Download" />
|
|
|
|
</a>
|
|
|
|
<!-- docs -->
|
|
|
|
<a href="https://docs.rs/dioxus">
|
|
|
|
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square"
|
|
|
|
alt="docs.rs docs" />
|
|
|
|
</a>
|
|
|
|
<!-- CI -->
|
|
|
|
<a href="https://github.com/jkelleyrtp/dioxus/actions">
|
|
|
|
<img src="https://github.com/dioxuslabs/dioxus/actions/workflows/main.yml/badge.svg"
|
|
|
|
alt="CI status" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
-----
|
|
|
|
|
|
|
|
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`:
|
|
|
|
|
2022-07-09 19:15:20 +00:00
|
|
|
```rust, ignore
|
2022-02-17 15:38:51 +00:00
|
|
|
static NAME: Atom<&str> = |_| "Dioxus";
|
|
|
|
```
|
|
|
|
|
2023-01-10 16:16:11 +00:00
|
|
|
From anywhere in our app, we can read the value of our atom:
|
2022-02-17 15:38:51 +00:00
|
|
|
|
2023-01-10 16:16:11 +00:00
|
|
|
```rust, ignores
|
2022-07-09 19:15:20 +00:00
|
|
|
fn NameCard(cx: Scope) -> Element {
|
2022-12-07 21:11:40 +00:00
|
|
|
let name = use_read(cx, NAME);
|
2022-02-17 15:38:51 +00:00
|
|
|
cx.render(rsx!{ h1 { "Hello, {name}"} })
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
We can also set the value of our atom, also from anywhere in our app:
|
|
|
|
|
2022-07-09 19:15:20 +00:00
|
|
|
```rust, ignore
|
|
|
|
fn NameCard(cx: Scope) -> Element {
|
2022-12-07 21:11:40 +00:00
|
|
|
let set_name = use_set(cx, NAME);
|
2022-02-17 15:38:51 +00:00
|
|
|
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.
|
|
|
|
|
2022-07-09 19:15:20 +00:00
|
|
|
```toml
|
2022-06-28 02:58:27 +00:00
|
|
|
[dependencies]
|
2022-09-06 18:42:45 +00:00
|
|
|
fermi = { git = "https://github.com/dioxuslabs/dioxus" }
|
2022-02-17 15:38:51 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Running examples
|
|
|
|
|
|
|
|
The examples here use Dioxus Desktop to showcase their functionality. To run an example, use
|
2022-11-22 17:56:15 +00:00
|
|
|
```sh
|
2022-09-06 18:42:45 +00:00
|
|
|
$ cargo run --example fermi
|
2022-02-17 15:38:51 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
2023-01-10 16:16:11 +00:00
|
|
|
Broadly our feature set required to be released includes:
|
2022-02-17 15:38:51 +00:00
|
|
|
- [x] Support for Atoms
|
2023-01-10 16:16:11 +00:00
|
|
|
- [x] Support for AtomRef (for values that aren't `Clone`)
|
2022-02-17 15:38:51 +00:00
|
|
|
- [ ] Support for Atom Families
|
|
|
|
- [ ] Support for memoized Selectors
|
|
|
|
- [ ] Support for memoized SelectorFamilies
|
2022-07-09 19:15:20 +00:00
|
|
|
- [ ] Support for UseFermiCallback for access to fermi from async
|