Skip to content

Commit

Permalink
Implement second arity of handle_call for :get atom in which it retur…
Browse files Browse the repository at this point in the history
…ns [] if inner state is empty
  • Loading branch information
alimoezzi committed Feb 13, 2021
1 parent d143ec0 commit 7f8e1b1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/procon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ defmodule Procon.Producer do
[h | t] = state
{:reply, h, t}
end

def handle_call(:get, _from, _state) do
# {:atom, oldstate, newstate}
{:reply, :none, []}
end

def handle_cast(:produce, state) do
spawn(fn -> Process.sleep(@delay) && GenServer.cast({:global, :producer}, :produce) end)
{:noreply, state ++ Enum.to_list(50..(2 * 50 + 1))}
Expand Down

0 comments on commit 7f8e1b1

Please sign in to comment.