Describe the bug
Steps preceding a switch execute multiple times. The code below will output 'MOO' and 'BOO' twice.
(It only happens if those steps do not halt).
The debug step also executes twice, not sure if that is ok.
To Reproduce
Reactor.run(SwitchReactor, %{value: true})
defmodule SwitchReactor do
@moduledoc false
use Reactor
input :value
debug :debug do
argument :value, input(:value)
end
step :moo do
argument :value, input(:value)
run fn %{value: value}, _ ->
IO.puts IO.ANSI.format([:yellow_background, :black, "MOOO"])
{:ok, value}
end
end
step :boo do
argument :value, input(:value)
wait_for :moo
run fn %{value: value}, _ ->
IO.puts IO.ANSI.format([:yellow_background, :black, "BOOO"])
{:ok, !value}
end
end
switch :is_truthy? do
on result(:boo)
matches? &(&1 in [nil, false]) do
# step :falsy, Noop
step :falsy do
argument :value, input(:value)
wait_for :boo
run fn %{value: value}, _ ->
IO.puts IO.ANSI.format([:yellow_background, :black, "falsy"])
{:ok, value}
end
end
return :falsy
end
default do
step :truthy, Noop
return :truthy
end
end
return :is_truthy?
end
Expected behavior
The steps should be executed only once.
Describe the bug Steps preceding a
switch
execute multiple times. The code below will output 'MOO' and 'BOO' twice. (It only happens if those steps do not halt). The debug step also executes twice, not sure if that is ok.To Reproduce
Reactor.run(SwitchReactor, %{value: true})
Expected behavior The steps should be executed only once.
Runtime