O'Reilly logo

Functional Web Development with Elixir, OTP, and Phoenix by Lance Halvorsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required