Programming Phoenix Liveview Part 2

Still working on getting started.

I am using phx.new version 1.6.15 which is slightly different to the book.
The mix phx.new command no longer has the –live flag so some of the expected templates are not there.
This means that page_live needed to be created manually and the route added.

This is my current version of that module. It’s probably not what. is expected but it is good enough.

defmodule PentoWeb.PageLive do
  use PentoWeb, :live_view

  def mount(_params, _session, socket) do
    {:ok, assign(socket, query: "123", results: %{})}
  end

  def render(assigns) do
    ~H"""
    <%= @query %>
    """
  end
end

I have also found that you get some exotic errors if you make a typo in an ~L template.

If you type phn-click instead of phx-click you get asked about some missing methods.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s