Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/intendednull/yewdux

Ergonomic state management for Yew applications
https://github.com/intendednull/yewdux

rust state state-container state-management store wasm web yew

Last synced: 6 days ago
JSON representation

Ergonomic state management for Yew applications

Awesome Lists containing this project

README

        

# Yewdux

Ergonomic state management for [Yew](https://yew.rs) applications.

See the [book](https://intendednull.github.io/yewdux/) for more details.

## Example

```rust
use yew::prelude::*;
use yewdux::prelude::*;

#[derive(Default, Clone, PartialEq, Store)]
struct State {
count: u32,
}

#[function_component]
fn ViewCount() -> Html {
let (state, _) = use_store::();
html!(state.count)
}

#[function_component]
fn IncrementCount() -> Html {
let (_, dispatch) = use_store::();
let onclick = dispatch.reduce_mut_callback(|counter| counter.count += 1);

html! {
{"+1"}
}
}

#[function_component]
fn App() -> Html {
html! {
<>


>
}
}

fn main() {
yew::Renderer::::new().render();
}
```