chronoscope/lib/chronoscope_web/live/index_live.ex

17 lines
378 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 16:25:27 -04:00
def handle_info(%{topic: @topic}, socket) do
{:noreply, assign(socket, %{servers: NTS.list()})}
2024-05-28 18:27:02 -04:00
end
end