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

#55 in WebAssembly

Download history 715/week @ 2023-11-20 399/week @ 2023-11-27 492/week @ 2023-12-04 556/week @ 2023-12-11 619/week @ 2023-12-18 248/week @ 2023-12-25 341/week @ 2024-01-01 668/week @ 2024-01-08 488/week @ 2024-01-15 643/week @ 2024-01-22 661/week @ 2024-01-29 694/week @ 2024-02-05 592/week @ 2024-02-12 533/week @ 2024-02-19 792/week @ 2024-02-26 632/week @ 2024-03-04

2,606 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
~274K SLoC