I have the following use case to solve which I believe is pretty standard: broadcast a Liveview page with several components which may have different hooks. Child Liveviews are ok. But with hooks, I am limited in the parent Liveview handle_info
(the one that responds to the broadcast_from
the event handlers) to only one {noreply, push_event(socket, event, payload)}
. How can I forward the broadcasted data when several events/hooks are listening to client side? Knowing that the listeners are global, maybe pass an array of {event, payload}
in the push_event?
To not leave this unanswered, you can have multiple times the same event handled by a handleEvent
, so just build the payload for each hook to cherry-pick from the payload. Nothing to invent.
2 Likes