GenServer Callbacks: handle_continue and handle_call
Learn how the GenServer uses handle_continue and handle_call to divide work and interact with processes.
The handle_continue callback function
The handle_continue/2 callback is a recent addition to GenServer. Often GenServer processes do complex work as soon as they start. Rather than blocking the whole application from starting, we return {:ok, state, {:continue, term}} from the init/1 callback and use handle_continue/2.
Return values
Accepted return values for handle_continue/2 include the following:
-
{:noreply, new_state} -
{:noreply, new_state, {:continue, term}} -
{:stop, reason, new_state}
{:noreply, new_state}
Since the handle_continue/2 callback receives the latest ...
Ask