/** * Produce transition to other state. * Return this from a state function in order to effect the transition. * * This method always triggers transition events, even for `A -> A` transitions. * If you want to stay in the same state without triggering an state transition event use [[#stay]] instead. * * @param nextStateName state designator for the next state * @return state transition descriptor */ final def goto(nextStateName: S): State = FSM.State(nextStateName, currentState.stateData) /** * Produce "empty" transition descriptor. * Return this from a state function when no state change is to be effected. * * No transition event will be triggered by [[#stay]]. * If you want to trigger an event like `S -> S` for `onTransition` to handle use `goto` instead. * * @return descriptor for staying in current state */ final def stay(): State = goto(currentState.stateName).withNotification(false) // cannot directly use currentState because of the timeout field
/** * Modify state transition descriptor with new state data. The data will be * set when transitioning to the new state. */ def using(@deprecatedName('nextStateDate) nextStateData: D): State[S, D] = {
copy(stateData = nextStateData) }
final def startWith(stateName: S, stateData: D, timeout: Timeout = None): Unit = currentState = FSM.State(stateName, stateData, timeout) final def goto(nextStateName: S): State = FSM.State(nextStateName, currentState.stateData) final def stay(): State = goto(currentState.stateName).withNotification(false) final def stop(): State = stop(Normal) final def transform(func: StateFunction): TransformHelper = new TransformHelper(func) ...
case class State[S, D](stateName: S, stateData: D, timeout: Option[FiniteDuration] = None, stopReason: Option[Reason] = None, replies: List[Any] = Nil) { ... // defined here to be able to override it in SilentState
def copy(stateName: S = stateName, stateData: D = stateData, timeout: Option[FiniteDuration] = timeout, stopReason: Option[Reason] = stopReason, replies: List[Any] = replies): State[S, D] = { new State(stateName, stateData, timeout, stopReason, replies) } /** * Modify state transition descriptor to include a state timeout for the * next state. This timeout overrides any default timeout set for the next * state. * * Use Duration.Inf to deactivate an existing timeout. */ def forMax(timeout: Duration): State