Reputation: 19456
I understand that I can get the liveview to update by including something like:
if connected?(socket), do: :timer.send_interval(10000, self(), :click)
But, is there a way to trigger this from somewhere else in my application?
For example, if you are updating traffic stats, you only want to update the control when a new click has arrived.
Upvotes: 3
Views: 627
Reputation: 428
You can use the PubSub mechanism. E.g. set Phoenix.PubSub.subscribe
on mount
and broadcast
in a click handle_event
Upvotes: 3