Visualization
Mix.install([
{:kino, path: "../kino/", override: true},
{:protean, path: "../protean/", override: true},
{:protean_kino, path: "./", override: true}
])
==> protean_kino
Compiling 1 file (.ex)
:ok
Section
import Protean.Builder
match(:foo, target: :bar)
{#Function<42.3316493/1 in :erl_eval.expr/6>, [_meta: %{expr: :foo}, target: :bar]}
defmodule MyMachine do
use Protean
@machine [
initial: :parallel,
states: [
parallel(:parallel,
entry: :foo,
states: [
compound(:parent,
initial: :child1,
on: [
match(:goto_sibling, target: :"#sibling", actions: [:one, :other])
],
states: [
atomic(:child1,
entry: Protean.Action.send(:message, to: :self),
exit: "go do a thing",
on: [
match(:goto_child2, target: :child2)
]
),
atomic(:child2,
on: [
match(%{foo: :bar}, actions: :do_a_thing, guard: {:not, :foo?})
]
)
]
),
atomic(:sibling)
]
),
final(:sibling)
]
]
@impl true
def handle_action(_, state, _), do: state
end
{:module, MyMachine, <<70, 79, 82, 49, 0, 0, 60, ...>>, {:handle_action, 3}}
{:ok, machine, id} = Protean.start_machine(MyMachine)
{:ok,
{:via, Registry,
{Protean.ProcessManager.Registry, {MyMachine, "48683a65-fb4f-487d-98a6-b99af704195a"}}},
"48683a65-fb4f-487d-98a6-b99af704195a"}
Protean.Kino.machine(MyMachine.__protean_machine__())