A Detail Explanation about
Elixir GenServer — Learn When, Where, & How to use ?
cast, call & info messages in Elixir & Erlang
Getting into new habit of programming is always a challenging task.
Learning is something that we shouldn’t stop until our last breathe. Practical learning with live examples will be an extra cheese to our interests. This helps us to do things better, faster.
Note:
Processes are the same in both Erlang and Elixir, so everything below is equally applicable to both languages.
This article comprises of Elixir Genserver and server callbacks with clean and clear explanation. It is intermediate level programmers topic. However, we shall be going with simple words to enrich your knowledge in understanding GenServer
callbacks and beginners can get the glimpse of it.
We shall go with theory part first there after we will dive in to practical demonstration.
Theory
— cast
handle_cast( message, state ) :: { :noreply, state }
The handle_cast
is used in situations like where you don’t care nor expect reply from the server.