Customizing GenServer Behavior
Spawning and initializing a new GenServer process is a great start, but the default callback implementations we got with use GenServer don’t go very far. In order to build real applications, we need to change the way a GenServer behaves to fit each application’s needs.
To do this, we’re going to follow the pattern we’ve used so far—write a client function that wraps a GenServer function that triggers a callback. The callback is where we’ll define the new behavior.
Each time we add a new public function, we build a new piece of the interface for the game. As we go along, we’ll expose more and more of the game’s behavior. This interface acts as a boundary between the rest of the system and a game. That makes it ...
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.