12 releases

0.10.0 Dec 19, 2023
0.9.4 Oct 10, 2023
0.9.3 Jun 1, 2023
0.9.2 Feb 23, 2023
0.6.1 Mar 19, 2021

#56 in WebAssembly

Download history 712/week @ 2024-03-13 985/week @ 2024-03-20 802/week @ 2024-03-27 737/week @ 2024-04-03 592/week @ 2024-04-10 774/week @ 2024-04-17 821/week @ 2024-04-24 932/week @ 2024-05-01 724/week @ 2024-05-08 614/week @ 2024-05-15 576/week @ 2024-05-22 639/week @ 2024-05-29 742/week @ 2024-06-05 787/week @ 2024-06-12 662/week @ 2024-06-19 582/week @ 2024-06-26

2,873 downloads per month
Used in 9 crates

MIT/Apache

62KB
1.5K SLoC

Yewdux

Ergonomic state management for Yew applications.

See the book for more details.

Example

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

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

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

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

    html! {
        <button {onclick}>{"+1"}</button>
    }
}

#[function_component]
fn App() -> Html {
    html! {
        <>
        <ViewCount />
        <IncrementCount />
        </>
    }
}

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

lib.rs:

Yewdux

Simple 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>
        </>
    }
}

Default exports

Dependencies

~11–15MB
~271K SLoC