yewv Rust

A lightning fast state management module for Yew built with performance and simplicity as a first priority.

Who is this for?

If you wish to use a store alongside Yew fonction components, this library is made for you.

Install

Add the following dependency to your Cargo.toml. toml [dependencies] yewv = "0.2"

Usage

The following need to be respected while using this library: 1. Only works with Yew function components. 2. Store and service contexts must be registered in a parent or root component with ContextProvider. 3. Store and service need to be used in a child component with use_store/use_service.

Simple app with store

```rust // main.rs use yew::prelude::; use yewv::;

struct AppState { count: i32, }

[function_component(App)]

fn app() -> Html { let store = StoreContext::new(AppState { count: 0 }); html! { > context={store}> >> } }

[function_component(Counter)]

fn counter() -> Html { let store = usestore::(); let count = store.mapref(|state| &state.count); let onclick = { let store = store.clone(); move || { let state = store.state(); store.setstate(AppState { count: state.count + 1, }); } }; html! {