Slide 46
Slide 46 text
defmodule YourProject.UserStateMachine do
@behaviour :gen_statem
@name :user_state_machine
def start_link do
:gen_statem.start_link({:local, @name}, __MODULE__, [], [])
end
def init([]) do
{:ok, :created, %{name: "Joe Doe"}}
end
def callback_mode do
:state_functions
end
def fill_data do
:gen_statem.call(@name, :fill_data)
end
def completed({:call, from}, :fill_data, data) do
{:next_state, :completed, data, [{:reply, from, :ok}]}
end
end