Show
Destroy
An entry
Get it down. Make it good. Share it.
Title
Text
Elixir GenServers are lightweight processes. GenServers provide a common interface for starting, stopping, and passing messages to and from. What you do from there is up to you. GenServer processes can be adorned with custom behavior. This is done using basic Elixir modules that `use GenServer`. Write a public interface for the client using basic methods. Then, write the internal handlers, using `handle_cast` and `handle_call`. ### Resources * https://elixircasts.io/intro-to-genserver * https://github.com/elixircastsio/012_introduction_to_genserver/blob/master/shopping_list.ex ## Try it out ``` # Start the GenServer and grab its PID (process ID) {:ok, pid} = ShoppingList.start_link() # Add milk, cheese, and eggs to the list ShoppingList.add(pid, "milk") ShoppingList.add(pid, "cheese") ShoppingList.add(pid, "eggs") # View the list ShoppingList.view(pid) # Remove cheese from the list ShoppingList.remove(pid, "cheese") # View the updated list ShoppingList.view(pid) ```
Status
idea
draft
release
personal
Series
Part of a Series?
Bitcoin
On Work
Phoenix Trello Tutorial
Civics
Re Email Address
Tags
notes
×
elixir
×
genserver
×
×
+
Slug
Url
Image 1
Image 2
Image 3
Visible
Date