Use a view model with Phoenix LiveView 👋 Andrew Timberlake

A view model pattern in Phoenix LiveView decouples UI state from domain models by wrapping records in a separate struct that adds UI-specific fields like selected and deleted, avoiding the need to pollute domain models with virtual fields or maintain separate tracking lists during render. The approach provides a clean way to access item state directly in templates (eg item_view.selected) while keeping the original model accessible within the view model for full data access.

Visit Original Article →

⌘K

Start typing to search...

Search across content, newsletters, and subscribers