leptos_tea

The Elm Architecture for leptos.

This crate is a particular strategy for state management in leptos. It follows the Elm architecture, but not strictly so, which allows mixing and matching with other state management approaches.

First, let's look at an example.

Example

```rust use leptos::*; use leptos_tea::Cmd;

[derive(Default, leptos_tea::Model)]

struct CounterModel { counter: usize, }

[derive(Default)]

enum Msg { Increment, Decrement, #[default] Init, }

fn update(model: UpdateCounterModel, msg: &Msg, _: Cmd) { match msg { Msg::Increment => model.counter.update(|c| *c += 1), Msg::Decrement => model.counter.update(|c| *c -= 1), Msg::Init => {} } }

[component]

fn Counter(cx: Scope) -> impl IntoView { let (model, msg_dispatcher) = CounterModel::default().init(cx, update);

view! { cx,

{model.counter}