chronoscope/lib/chronoscope_web/live/index_live.ex

18 lines
427 B
Elixir

defmodule ChronoscopeWeb.IndexLive do
use ChronoscopeWeb, :live_view
alias Chronoscope.NTS
alias Chronoscope.NTS.KeyEstablishmentResponse
@topic "nts-servers"
def mount(_params, _session, socket) do
ChronoscopeWeb.Endpoint.subscribe(@topic)
{:ok, assign(socket, %{servers: NTS.list()})}
end
def handle_info(%{topic: @topic}, socket) do
{:noreply, assign(socket, %{servers: NTS.list()})}
end
end