Elixir gen_fsm example

Run Settings
LanguageElixir
Language Version
Run Command
{:ok, fsm} = FooFsm.start_link() FooFsm.foo(fsm) FooFsm.bar(fsm) FooFsm.foo(fsm)
defmodule FooFsm do @behaviour :gen_fsm def start_link() do :gen_fsm.start_link(__MODULE__, :ok, []) end def foo(pid) do :gen_fsm.send_event(pid, :foo) end def bar(pid) do :gen_fsm.send_event(pid, :bar) end def init(:ok) do {:ok, :foo_state, []} end def foo_state(:foo, state) do IO.puts "foo state!" {:next_state, :bar_state, state} end def bar_state(:bar, state) do IO.puts "bar state!" {:next_state, :foo_state, state} end def handle_event(_event, state_name, state) do {:next_state, state_name, state} end def handle_sync_event(_event, _from, state_name, state) do {:next_state, state_name, state} end def handle_info(:stop, _state_name, state) do {:stop, :normal, state}; end def handle_info(_Info, state_name, state) do {:next_state, state_name, state} end def code_change(_OldVsn, state_name, state, _extra) do {:ok, state_name, state} end def terminate(reason, _state_name, _state) do reason end end
Editor Settings
Theme
Key bindings
Full width
Lines