chai-tea 0.1.0

A minimal Elm-style architecture for egui/eframe apps.
Documentation
  • Coverage
  • 66.67%
    2 out of 3 items documented1 out of 2 items with examples
  • Size
  • Source code size: 110.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.83 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2m 9s Average build duration of successful builds.
  • all releases: 2m 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • ryry0/chai-tea-rs
    2 1 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ryry0

🍵 chai-tea

a minimal Elm-style architecture for egui / eframe apps

Status: experimental — minimal working example only. API may change rapidly as development continues.


chai-tea lets you write GUI apps in the same clean loop you’d use in The Elm Architecture (TEA):

use eframe::egui;

#[derive(Default)]
struct Model { counter: i32 }
enum Msg { Inc, Dec }

fn init() -> Model { Model { counter: 0 } }

fn update(m: Model, msg: Msg) -> Model {
    match msg {
        Msg::Inc => Model { counter: m.counter + 1, ..m },
        Msg::Dec => Model { counter: m.counter - 1, ..m },
    }
}

fn view(ctx: &egui::Context, m: &Model, tx: &mut Vec<Msg>) {
    egui::CentralPanel::default().show(ctx, |ui| {
        if ui.button("+").clicked() { tx.push(Msg::Inc); }
        if ui.button("").clicked() { tx.push(Msg::Dec); }
        ui.label(m.counter.to_string());
    });
}

fn main() -> eframe::Result<()> {
    chai_tea::run(init, update, view)
}

add eframe to your dependencies, run it and you’ve got a fully working counter app.

cargo run --example counter

✨ features

  • pure Elm-style loop (Model → Msg → update → view)
  • works on native and wasm targets (coming soon)
  • tiny and dependency-light

🫖 possible roadmap

  • async / background command support
  • fixed-timestep threaded simulation variant
  • wasm runner (chai_tea::run_web)
  • macro sugar: #[chai_app]
  • theme system (chai-latte someday?)
  • time travel debugger?