The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

oldfartdeveloper (18) [Avatar] Offline
#1
In the first code block in section 6.2.8:

defmodule TodoServer do
  use GenServer

  def init(_) do
    :timer.send_interval(5000, :todo_cleanup)
    {:ok, nil}
  end
end


The problem is that you are completely diverting from the "other" requirement of the "init" method which is to initialize a TodoList.

Hence, shouldn't it be written as:

defmodule TodoServer do
  use GenServer

  def init(_) do
    :timer.send_interval(5000, :todo_cleanup)
    {:ok, TodoList.new}  # <==== HERE! remember what we were doing!
  end
end


Or, if you want to deviate from "the other" problem you're discussing, then change the name of the module altogether, i.e.

defmodule SomeServer do
  use GenServer

  def init(_) do
    :timer.send_interval(5000, :some_cleanup)
    {:ok, nil}
  end
end


This way, there is no ambiguity of what your intention is at this point in the book.

HTH,

Scott
sjuric (109) [Avatar] Offline
#2
Thank you for reporting. I caught this myself while doing some changes to chapter 6. Using a nil for the initial state doesn't make sense here. The changed version will be included in the next release.