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

#677 in Web programming

Download history 1339/week @ 2024-09-02 804/week @ 2024-09-09 669/week @ 2024-09-16 959/week @ 2024-09-23 549/week @ 2024-09-30 362/week @ 2024-10-07 630/week @ 2024-10-14 705/week @ 2024-10-21 562/week @ 2024-10-28 672/week @ 2024-11-04 670/week @ 2024-11-11 521/week @ 2024-11-18 834/week @ 2024-11-25 806/week @ 2024-12-02 1168/week @ 2024-12-09 816/week @ 2024-12-16

3,671 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

~12–20MB
~282K SLoC