#yew #state #redux #shared #container

macro yewdux-macros

Ergonomic state management for Yew applications

6 releases

0.9.2 Feb 23, 2023
0.9.1 Feb 22, 2023
0.9.0 Nov 25, 2022
0.8.3 Nov 1, 2022
0.8.1 Aug 19, 2022

#5 in #state-container

Download history 569/week @ 2022-12-09 519/week @ 2022-12-16 270/week @ 2022-12-23 423/week @ 2022-12-30 405/week @ 2023-01-06 290/week @ 2023-01-13 528/week @ 2023-01-20 552/week @ 2023-01-27 624/week @ 2023-02-03 694/week @ 2023-02-10 965/week @ 2023-02-17 881/week @ 2023-02-24 809/week @ 2023-03-03 737/week @ 2023-03-10 726/week @ 2023-03-17 756/week @ 2023-03-24

3,285 downloads per month
Used in 6 crates (via yewdux)

MIT/Apache

5KB
90 lines

Yewdux

Ergonomic state management for Yew applications.

See the book for more details.

Example

use yew::prelude::*;
use yewdux::prelude::*;

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

#[function_component]
fn App() -> Html {
    let (state, dispatch) = use_store::<State>();
    let onclick = dispatch.reduce_mut_callback(|state| state.count += 1);

    html! {
        <>
        <p>{ state.count }</p>
        <button {onclick}>{"+1"}</button>
        </>
    }
}

fn main() {
    yew::Renderer::<App>::new().render();
}

Dependencies

~1–1.5MB
~34K SLoC