phoenix-thinking
Installation
SKILL.md
Phoenix Thinking
Mental shifts for Phoenix applications. These insights challenge typical web framework patterns.
Where to Load Data: mount vs handle_params
Default: load data in mount/3.
def mount(_params, _session, socket) do
posts = Blog.list_posts(socket.assigns.current_scope)
{:ok, assign(socket, posts: posts)}
end
Yes, mount runs twice on initial load (HTTP dead render + WebSocket connect). So does handle_params/3. That's the LiveView lifecycle, not a bug to route around. Moving queries from mount to handle_params does not dedupe them.
Use handle_params/3 for data that changes on live navigation (push_patch / <.link patch={...}>). mount does not re-run on patches, handle_params does.