VPC Regeneration
Zuraffa supports granular regeneration of your presentation layer, allowing you to evolve your business logic without losing custom UI work. By using flags like --pc and --pcs, you can target specific components for updates while preserving your carefully crafted Views.
π¦ The VPC Patternβ
Zuraffa's presentation layer is built on the View-Presenter-Controller (VPC) pattern:
- View: Pure Flutter UI code.
- Presenter: Orchestrates UseCases and prepares data.
- Controller: Manages user interactions and feature lifecycle.
- State: The single source of truth for the UI.
π Regeneration Flagsβ
Zuraffa gives you full control over what gets updated:
| Flag | Generated Components | Best Use Case |
|---|---|---|
--vpcs | View, Presenter, Controller, State | Initial feature scaffolding. |
--pcs | Presenter, Controller, State | Adding new methods or state fields while keeping custom UI. |
--pc | Presenter, Controller | Updating logic without changing the State structure. |
--view | View only | Resetting or regenerating the UI layer. |
π οΈ Common Workflowsβ
1. Adding New Functionalityβ
Suppose you have a Product feature and want to add a watch capability without touching your custom UI:
zfa feature Product --methods=watch --pcs --force
This will:
- Generate the
WatchProductUseCase. - Add the UseCase to the
ProductPresenter. - Add a
isWatchingflag andcurrentProductstream toProductState. - Update
ProductControllerto handle the subscription. - Preserve your existing
ProductView.
2. Evolving Stateβ
If you need more granular loading indicators (e.g., isCreating, isUpdating), Zuraffa can regenerate the State object and the logic to drive it:
zfa feature Product --methods=create,update --pcs --force
π§ Smart Injectionβ
When you regenerate a Presenter, Zuraffa's AST-aware generator doesn't just overwrite the fileβit intelligently injects new UseCase dependencies into the constructor and registers them using registerUseCase(). This ensures that your manual customizations in other parts of the file are preserved whenever possible.
π Next Stepsβ
- UseCase Types - Learn about the business logic driving your VPC.
- CLI Reference - Master all generation flags.