Elixir Blog Posts

I save to stash on each call instead of terminate.

  def handle_call(..., state) do
    ...
    reply_success(state, :ok)
  end

  defp reply_success(state, reply) do
    name = state.uuid
    persist_state(name, state)
    {:reply, reply, state, @timeout}
  end

As mentionned, terminate is not always executed. It allows me to configure call replies on one spot.

4 Likes