Agent is an abstraction over GenServer. It is used when we want to store and retrieve only the data from the process without doing any additional logic.
- On start we initialize the state. We pass a function and the return value of it is assigned to the initial state.
- If we want to retrieve the state, we pass a function which takes state as parameter and manipulates it to return back what and how we want.
- If we want to update the state, again a function is passed which takes parameter as list and the return value of the function is assigned to the state.
Check my book for Elixir starters at https://gum.co/XgbKSE