Example implementations of lists using GPUI.
# Run the simple list example (default)
cargo run
# Or explicitly:
cargo run --bin simple
# Run the global list example
cargo run --bin globalThe simple_list example has the model and list in one view. It demonstrates basic list state management with event emission to update the list when items are added.
The global_list example leverages a model in the global context. This demonstrates how sibling components can independently read from and react to shared state.
┌─────────────────────────────────┐
│ Workspace │
├─────────────────────────────────┤
│ Header │ List │ Input │ ← sibling components
│ ↓ ↓ ↓ │
│ GlobalStateModel │ ← all subscribe independently
└─────────────────────────────────┘
Components:
- Header - Subscribes to state changes and displays the total item count
- List - Subscribes to state changes and rebuilds the list when items are added
- Input - Triggers state updates via
StateModel::update()/push()
All three components subscribe to AddListItemEvent independently, demonstrating a scalable architecture pattern where components react to global state changes without direct coupling to each other.
The common ListItem component and shared utilities are in common.rs.
