Expand description
Choreographic Programming for multi-widget interactions (bd-14k2m).
Defines coordinated multi-widget behavior from a global specification and automatically projects it to per-widget message handlers.
§Motivation
In Elm/Bubbletea architecture, coordinated behavior across multiple widgets requires manually routing messages. Missing a message means inconsistent state. Choreographic programming (Montesi 2013) eliminates this class of bugs by:
- Define the choreography once (global specification).
- Project to individual widgets automatically.
- Guarantee completeness (no missing messages).
§Example
use ftui_widgets::choreography::*;
let mut choreo = Choreography::new("filter_update");
// Global specification: when filter changes, update list + status + header
choreo.step("filter", Action::Emit("filter_changed".to_string()));
choreo.step(
"list",
Action::Handle("filter_changed".to_string(), "scroll_to_top".to_string()),
);
choreo.step(
"status",
Action::Handle("filter_changed".to_string(), "update_count".to_string()),
);
choreo.step(
"header",
Action::Handle("filter_changed".to_string(), "highlight_filter".to_string()),
);
// Project to per-widget handlers
let projection = choreo.project();
assert_eq!(projection.handlers("filter").len(), 1);
assert_eq!(projection.handlers("list").len(), 1);
assert_eq!(projection.handlers("status").len(), 1);
assert_eq!(projection.handlers("header").len(), 1);
// Verify deadlock freedom
assert!(choreo.verify_deadlock_free());Structs§
- Choreography
- A global choreography specification.
- Choreography
Step - A single step in a choreography.
- Completeness
Report - Report on choreography completeness.
- Execution
Event - An event from choreography execution.
- Projected
Handler - A projected handler for a single participant.
- Projection
- Projected per-participant handlers from a choreography.
Enums§
- Action
- An action in a choreography step.
- Event
Kind - Kind of execution event.
- Handler
Kind - Kind of projected handler.
Functions§
- example_
filter_ update - Filter update: filter dropdown → list + status bar + header.
- example_
modal_ dialog - Modal dialog: trigger → overlay + dimmer + focus trap.
- example_
search_ flow - Search flow: search input → results list → status + preview.
- example_
selection_ sync - Selection sync: list selection → detail panel + status bar.
- example_
tab_ navigation - Tab navigation: tab bar → content panel + breadcrumb + status.
- execute_
choreography - Execute a choreography against a set of participant state callbacks.
Type Aliases§
- Message
Type - A message type exchanged between participants.
- Participant
Id - A participant in a choreography (typically a widget).