Skip to main content

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:

FlagGenerated ComponentsBest Use Case
--vpcsView, Presenter, Controller, StateInitial feature scaffolding.
--pcsPresenter, Controller, StateAdding new methods or state fields while keeping custom UI.
--pcPresenter, ControllerUpdating logic without changing the State structure.
--viewView onlyResetting 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:

  1. Generate the WatchProductUseCase.
  2. Add the UseCase to the ProductPresenter.
  3. Add a isWatching flag and currentProduct stream to ProductState.
  4. Update ProductController to handle the subscription.
  5. 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​