StateMachine
StateMachine copied to clipboard
Throw exception on the wrong event
What if state machine will throw an exception when we try to do transition to some state by undeclared event (sorry for my english). For example: declaring state machine behaviour
initialState(State.SomeState)
state<State.SomeState> {
on<Event.SomeEvent> {
transitionTo(State.AnotherState, SideEffect.SomeSideEffect)
}
}
then we trying to do undeclared transition (from state "SomeState")
stateMachine.transition(Event.SomeOtherEvent) //<- there is should be thrown an exception
@Keyrillanskiy Currently, when that happens (undeclared event), it returns a Transition.Invalid
object. Does that work for you?
@zhxnlai Just in my opinion, when FSM doing something wrong, there is should be an exception ¯_(ツ)_/¯