Skip to content

Instantly share code, notes, and snippets.

@Ayoush
Created August 28, 2020 09:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
defmodule OtpConceptsProcesses do
def start_link() do
spawn_link(__MODULE__, :loop, [%{}])
end
def loop(state) do
receive do
{:add, value} ->
new_state = Map.put(state, :add, value)
loop(new_state)
{:remove, value} ->
new_state = Map.put(state, :remove, value)
loop(new_state)
loop(state)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment