we don't need to pass self() on to client functions

This commit is contained in:
Rüdiger Diedrich
2022-07-25 11:04:46 +02:00
parent de9afd2907
commit bd8177a7c0
2 changed files with 41 additions and 10 deletions

View File

@ -3,15 +3,15 @@ defmodule SomethingErlang.Grover do
require Logger
def mount(lv_pid, user, thread_id) do
def mount(user, thread_id) do
DynamicSupervisor.start_child(
SomethingErlang.Supervisor.Grovers,
{__MODULE__, [lv_pid, user, thread_id]}
{__MODULE__, [self(), user, thread_id]}
)
end
def get_thread!(lv_pid, thread_id, page_number) do
GenServer.call(via(lv_pid), {:show_thread, thread_id, page_number})
def get_thread!(thread_id, page_number) do
GenServer.call(via(self()), {:show_thread, thread_id, page_number})
end
def start_link([lv_pid, user, thread_id]) do
@ -47,9 +47,9 @@ defmodule SomethingErlang.Grover do
Logger.debug "received :DOWN from: #{inspect(state.lv_pid)} reason: #{inspect(reason)}"
case reason do
{:shutdown, _} -> {:stop, :normal, state}
:killed -> {:stop, :normal, state}
_ -> {:noreply, state}
end
|> IO.inspect()
end
defp via(lv_pid),