...

/

Implementing the QuizManager with Processes

Implementing the QuizManager with Processes

Let's start creating our first GenServer, the quiz manager.

We'll cover the following...

QuizManager

The quiz manager will start with an empty map:

  • We’ll add quizzes to it through a call to :build_quiz.

  • Then, we’ll add templates to a quiz in the store through a call to :add_template.

  • We’ll add a function to let our users look up a quiz by name.

Declaring our boundary

We’ll open up /lib/mastery/boundary/quiz_manager.ex. It’s a straight Elixir module that looks like this:

defmodule Mastery.Boundary.QuizManager do
alias Mastery.Core.Quiz
use GenServer
end
  • We declare the module and setup our initial aliases for Quiz.

  • Then we use GenServer. The use function is an Elixir macro. As we know, macros are code that ...