diff --git a/lib/counter_web/live/counter_state.ex b/lib/counter/counter_state.ex similarity index 81% rename from lib/counter_web/live/counter_state.ex rename to lib/counter/counter_state.ex index 855844b..e886428 100644 --- a/lib/counter_web/live/counter_state.ex +++ b/lib/counter/counter_state.ex @@ -12,7 +12,12 @@ defmodule Counter.Count do end def start_link(_opts) do - GenServer.start_link(__MODULE__, @start_value, name: @name) + with {:ok, pid} <- GenServer.start_link(__MODULE__, @start_value, name: @name) do + {:ok, pid} + else + {:error, {:already_started, pid}}-> {:ok, pid} + {:error, other} -> {:error, other} + end end def incr() do