diceline-chartmagnifiermouse-upquestion-marktwitter-whiteTwitter_Logo_Blue

Today I Learned

Make LiveView template variables readable

If you ever seen this in the wild:

{:ok, assign(socket,
      %{my_variable: @my_variable
        my_other_variable: nil.
        yet_another_variable: nil 
      })}

Remember that applying elixir's pipe operator makes everything better:

def mount(_session, socket) do
    socket =
      socket
      |> assign(:my_variable, @my_variable)
      |> assign(:my_other_variable, nil)
      |> assign(:yet_another_variable, nil)
    {:ok, socket}
end