GenServer.reply
You're seeing just the function
reply
, go back to GenServer module for more information.
Specs
Replies to a client.
This function can be used to explicitly send a reply to a client that called
call/3
or multi_call/4
when the reply cannot be specified in the return
value of handle_call/3
.
client
must be the from
argument (the second argument) accepted by
handle_call/3
callbacks. reply
is an arbitrary term which will be given
back to the client as the return value of the call.
Note that reply/2
can be called from any process, not just the GenServer
that originally received the call (as long as that GenServer communicated the
from
argument somehow).
This function always returns :ok
.
Examples
def handle_call(:reply_in_one_second, from, state) do
Process.send_after(self(), {:reply, from}, 1_000)
{:noreply, state}
end
def handle_info({:reply, from}, state) do
GenServer.reply(from, :one_second_has_passed)
{:noreply, state}
end