No the code you sent connects you to a phoenix channel. This also uses websockets, but all it does is provide an API for javascript code to send events into and receive events from the server. LiveView (while implemented on top of channels) is distinct and requires its own JS. You can see an example here: phoenix_live_view_example/assets/js/app.js at master · chrismccord/phoenix_live_view_example · GitHub
If this is an existing phoenix application you’ll need to sort of “retrofit” channels to it which may be relatively challenging for a junior that is new to phoenix. You can find docs for this however here: https://hexdocs.pm/phoenix_live_view/installation.html
Nah don’t! There’s a lot here and you’re new!
It is an existing project but it is recent enough that there is support for liveview
hopefully i wont have to manually do this retrofitting you are talking about.
Anywho, thanks
for the help
Just to wrap up my understanding of the problem:
My mount fn is called twice, once when the page loads initially, and afterwards for each liveSocket that connects.
Since i never connected, the first process to subscribe got killed after the first mount.
And, I never even connected because I didn’t do the frontend logic to actually connect to the liveview, no livesocket actually existed to push an update onto, thus my handle_info never got called
TL:DR: i got confused between LiveViews and Channels/sockets and thus never updated my view
No, each connection has it’s own liveview process living in the backend.
It never subscribed because You did not connect from the frontend.
They are close friends… channels are the manual way, You would use them with a JS frontend, like React. And LiveView is using them under the hood