chronoscope/lib/chronoscope_web/live/index_live.ex

17 lines
393 B
Elixir
Raw Normal View History

2024-05-28 18:27:02 -04:00
defmodule ChronoscopeWeb.IndexLive do
use ChronoscopeWeb, :live_view
2024-05-29 15:25:05 -04:00
alias Chronoscope.NTS
@topic "nts-servers"
2024-05-28 18:27:02 -04:00
def mount(_params, _session, socket) do
ChronoscopeWeb.Endpoint.subscribe(@topic)
2024-05-29 15:25:05 -04:00
{:ok, assign(socket, %{servers: NTS.list()})}
2024-05-28 18:27:02 -04:00
end
2024-05-29 15:25:05 -04:00
def handle_info(%{topic: @topic, payload: servers}, socket) do
{:noreply, assign(socket, %{servers: servers})}
2024-05-28 18:27:02 -04:00
end
end