I want to render a loading template until the second mount is called on socket connection, but don’t quite follow the best way to do that.
I’ve been using phx.gen.live
to get a sample app going and basically have this:
# myapp_web/live/page_live.ex
def mount(_params, _session, socket) do
if connected?(socket) do
socket = socket
|> assign(:steps, "blabla")
|> assign(:activity_minutes, "blabla")
{:ok, socket}
else
{:ok, assign(socket, page: "loading")}
end
end
def render(%{page: "loading"} = assigns) do
~L"<div>Loading...</div>"
end
I would have thought that render would have to use the default behavior if the method signature didn’t match - rendering myapp_web/live/page_live.html.leex
. How do I force it to do so?
I see in the documentation, I should be able to call render SomeView, "child_template.html", assigns
I was hoping I didn’t need to setup an empty “dead view” to achieve this result. Or am I mistaken?
Thanks in advance for any help you could offer!
-Mario