Getting Started with GenServer
GenServers are everywhere in Elixir code. Becoming proficient with GenServer is one of the best things you can do to level up as an Elixir developer. It will require some work on your part. You’ll need to learn how client functions, module functions, and callbacks work and interact.
But honestly, implementing a GenServer is pretty straightforward. We’ll get lots of practice in this chapter, so you’ll come out of it knowing your way around.
Let’s begin with a new file in the lib directory called lib/islands_engine/game.ex. This will define a new module that will become our GenServer.
| defmodule IslandsEngine.Game do |
| use GenServer |
| end |
By adding the use GenServer line, we already have the beginnings of ...
Get Functional Web Development with Elixir, OTP, and Phoenix now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.