Created
November 22, 2017 02:56
-
-
Save jlerche/e01ac0e3ae2918277d674aa80be6dbd5 to your computer and use it in GitHub Desktop.
A naive genserver constant store
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Store do | |
use GenServer | |
def start_link(state \\ [:foo]) do | |
GenServer.start_link(__MODULE__, state, name: __MODULE__) | |
end | |
def init(state), do: {:ok, state} | |
def get, do: GenServer.call(__MODULE__, :get) | |
def handle_call(:get, _from, state), do: {:reply, state, state} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment