BB.Command.SetState (bb v0.15.0)
View SourceReusable command handler for transitioning between operational states.
Use this handler to define simple state transition commands without implementing a custom handler. The target state is specified in the handler options.
Usage
commands do
command :enter_recording do
handler {BB.Command.SetState, to: :recording}
allowed_states [:idle]
end
command :exit_recording do
handler {BB.Command.SetState, to: :idle}
allowed_states [:recording]
end
endThen execute:
{:ok, cmd} = MyRobot.enter_recording()
{:ok, :recording} = BB.Command.await(cmd)
BB.Robot.Runtime.state(MyRobot) # => :recordingHandler Options
:to(required) - The target state to transition to. Must be defined in the robot'sstatessection.