12 个版本

0.10.0 2023 年 12 月 19 日
0.9.4 2023 年 10 月 10 日
0.9.3 2023 年 6 月 1 日
0.9.2 2023 年 2 月 23 日
0.6.1 2021 年 3 月 19 日

86WebAssembly 中排名

Download history · Rust 包仓库 932/week @ 2024-05-01 · Rust 包仓库 724/week @ 2024-05-08 · Rust 包仓库 614/week @ 2024-05-15 · Rust 包仓库 576/week @ 2024-05-22 · Rust 包仓库 639/week @ 2024-05-29 · Rust 包仓库 742/week @ 2024-06-05 · Rust 包仓库 787/week @ 2024-06-12 · Rust 包仓库 649/week @ 2024-06-19 · Rust 包仓库 608/week @ 2024-06-26 · Rust 包仓库 547/week @ 2024-07-03 · Rust 包仓库 438/week @ 2024-07-10 · Rust 包仓库 644/week @ 2024-07-17 · Rust 包仓库 607/week @ 2024-07-24 · Rust 包仓库 722/week @ 2024-07-31 · Rust 包仓库 1080/week @ 2024-08-07 · Rust 包仓库 815/week @ 2024-08-14 · Rust 包仓库

3,314 每月下载量
用于 9 crate

MIT/Apache

62KB
1.5K SLoC

Yewdux

Yew 应用程序提供便捷的状态管理。

更多信息请参阅 书籍

示例

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

Yew 应用程序提供简单的状态管理。

更多信息请参阅 书籍

示例

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

默认导出

依赖

~11–16MB
~277K SLoC