cjm2671
cjm2671

Reputation: 19456

How do I tell a Phoenix LiveView to update?

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

Answers (1)

RobChooses
RobChooses

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

Related Questions