When can `connected?` return false in the `mount` callback?

I was reading the liveview documentation and came across this:

After the client connects, mount/3 will be invoked inside a spawned LiveView process. At this point, you can use connected?/1 to conditionally perform stateful work, such as subscribing to pubsub topics, sending messages, etc.

But when going to the documentation of connected? itself I read:

Once the client connects to the server, a LiveView is then spawned and mounted
statefully within a process.

If I read these correctly, mount is called when the clients connects to the server. So when can connected? return false in the mount callback?

A liveview is also rendered statically when requested through a plain http request. At that point connected? is false, as it’s not initiated by a websocket request.

1 Like

Ah yes, this is clear from: https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:mount/3

Thanks!

1 Like