I have a simple one page app with a selectable list and an image. Based on what is clicked on the list, the image will be changed.
The selectable list is implemented as a LiveComponent
and, when an entry is selected, the SelectableList
sends a broadcast as:
MyAppWeb.Endpoint.broadcast!(
"selectable_list_channel",
"entry_selected",
%{
id: socket.assigns.id,
data: some_selected_data)})
I understand this may not be optimal way to handle this (I am open to suggestions), however it creates another layer of problems.
That is, when the app is called from two tabs (sessions) simultaneously, the user clicking in one session will trigger changes for the other user.
How to properly track that? I have considered using Phoenix Live Session
, but it turned out that I can not call put_session
from the component. How can I make the component communicate only with the liveview withing session which created them?