concept callback in category elixir

appears as: callbacks, callbacks, callback, The callback, callback
The Little Elixir & OTP Guidebook

This is an excerpt from Manning's book The Little Elixir & OTP Guidebook.

Let’s go through the last row. Say you want to stop the worker process, and you call Metex.Worker.stop/1. This will in turn invoke GenServer.cast/2, passing in pid and :stop as arguments. The callback that’s triggered is Metex.Worker.handle_cast (:stop, state). If the callback returns a tuple of the form {:stop, :normal, state}, then Metex.Worker.terminate/2 is invoked.

Six callbacks are automatically defined for you. Each callback expects a return value that conforms to what GenServer expects. Table 4.2 summarizes the callbacks, the functions that call them, and the expected return values. You’ll find the table especially helpful when you need to figure out the exact return values that each callback expects. I find myself referring to this table constantly.