Examples Overview
This repo includes starter examples. For more complete apps, see dmk/tui-stuff.
Counter
The simplest possible tui-dispatch app - increment/decrement a counter. Start here.
Demonstrates:
- Core pattern in ~80 lines
- State, Actions, Reducer, Store
- Event loop and conditional render
GitHub Lookup
A GitHub user lookup TUI. Good next step after Counter.
Demonstrates:
- Async API calls with
Did*action pattern - TaskManager for HTTP cancellation
- Loading states and error handling
- Text input handling
Markdown Preview
A markdown file viewer with debug overlay and feature flags.
Demonstrates:
- Debug layer with F12 toggle
- State inspection overlay
- Feature flags (line numbers, wrap, stats)
- Search with navigation
Log Viewer
A structured log viewer for files and stdin streams.
Demonstrates:
- ComponentHost with multiple mounted widgets
- Routed widget commands through EventBus and Keybindings
- Debug components overlay for widget-local state
- JSON log parsing, filtering, follow mode, and details inspection
Minesweeper
A minesweeper game demonstrating middleware cancel/inject patterns.
Demonstrates:
- Middleware for game logic (mine placement on first click)
- Cancel/inject action patterns
- Grid-based UI rendering
To inspect the game with the standalone debugger, start it with a socket path in a private directory:
mkdir -p -m 700 /tmp/minesweeper-debugcargo run -p minesweeper-example -- --debug-socket /tmp/minesweeper-debug/app.sockThen, from the repository root in another terminal:
cargo run -p tui-dispatch-debug --bin tui-dispatch-debug -- /tmp/minesweeper-debug/app.sockPlay in the game terminal; the debugger shows the last 64 action boundaries and
their state snapshots, including middleware cancellations and injected reveals.
For a predictable cancellation, flag a cell with f, then press Space on it.
Quitting the debugger leaves the game running; quitting the game removes its
socket. Add --once to the debugger command to print one JSON snapshot instead.
Running Examples
From the repository root:
# Counter - the minimal examplecargo run -p counter-example
# GitHub Lookupcargo run -p github-lookup-example
# Log viewercargo run -p log-viewer-example --bin log-viewer -- --help
# Markdown preview (default: README.md)cargo run -p md-preview-example --bin mdpreview
# Markdown preview with debug modecargo run -p md-preview-example --bin mdpreview -- path/to/file.md --debug
# Minesweepercargo run -p minesweeper-exampleMore Examples
See dmk/tui-stuff for larger apps built with tui-dispatch.