PseudoState

interface PseudoState : State

Pseudo state is a state that machine passes automatically without explicit event. It cannot be active.

Inheritors

Properties

Link copied to clipboard
abstract val childMode: ChildMode
Link copied to clipboard
abstract val initialState: IState?
Link copied to clipboard
abstract val isActive: Boolean
Link copied to clipboard
abstract val isFinished: Boolean
Link copied to clipboard
Link copied to clipboard
abstract val machine: StateMachine
Link copied to clipboard
abstract var metaInfo: MetaInfo?

Might be changed only during machine setup.

Link copied to clipboard
abstract val name: String?
Link copied to clipboard
abstract val parent: IState?
Link copied to clipboard
abstract var payload: Any?

Arbitrary user defined data. The property allows to store some data in a state without subclassing it. This might be handy in same simple use cases.

Link copied to clipboard
abstract val states: Set<IState>
Link copied to clipboard
abstract val transitions: Set<Transition<*>>

Functions

Link copied to clipboard
open suspend override fun accept(visitor: CoVisitor)
open override fun accept(visitor: Visitor)
Link copied to clipboard
fun IState.activeStates(selfIncluding: Boolean = false): Set<IState>

Set of states that the state is currently in. Including state itself if selfIncluding is true. Internal states of nested machines are not included.

Link copied to clipboard
fun <S : IFinalState> IState.addFinalState(state: S, init: StateBlock<S>? = null): S

Helper method for adding final states. This is exactly the same as simply call IState.addState but makes code more self expressive.

Link copied to clipboard
fun <S : IState> IState.addInitialState(state: S, init: StateBlock<S>? = null): S

A shortcut for IState.addState and IState.setInitialState calls

Link copied to clipboard
abstract fun <L : IState.Listener> addListener(listener: L): L
Link copied to clipboard
abstract fun <S : IState> addState(state: S, init: StateBlock<S>? = null): S
Link copied to clipboard
abstract fun <E : Event> addTransition(transition: Transition<E>): Transition<E>
Link copied to clipboard
abstract fun asState(): IState

For internal use only

Link copied to clipboard
inline fun <D : Any> IState.choiceDataState(name: String? = null, noinline choiceAction: suspend EventAndArgument<*>.() -> DataState<D>): DefaultChoiceDataState<D>
Link copied to clipboard
fun IState.choiceState(name: String? = null, choiceAction: suspend EventAndArgument<*>.() -> State): DefaultChoiceState
Link copied to clipboard
inline fun <D : Any> IState.dataState(name: String? = null, defaultData: D? = null, childMode: ChildMode = ChildMode.EXCLUSIVE, dataExtractor: DataExtractor<D> = defaultDataExtractor(), noinline init: StateBlock<DataState<D>>? = null): DefaultDataState<D>
Link copied to clipboard

Creates type safe argument transition to DataState.

inline fun <E : DataEvent<D>, D : Any> TransitionStateApi.dataTransition(name: String? = null, targetState: DataState<D>, type: TransitionType = LOCAL, metaInfo: MetaInfo? = null): Transition<E>

Shortcut function for type safe argument transition. Data transition can be target-less (self-targeted), it is useful to update DataState data Note that transition must be TransitionType.EXTERNAL to update data.

Link copied to clipboard

Data transition, otherwise same as transitionOn

Link copied to clipboard
inline fun <D : Any> IState.finalDataState(name: String? = null, defaultData: D? = null, dataExtractor: DataExtractor<D> = defaultDataExtractor(), noinline init: StateBlock<FinalDataState<D>>? = null): DefaultFinalDataState<D>
Link copied to clipboard
fun IState.finalState(name: String? = null, init: StateBlock<FinalState>? = null): DefaultFinalState
Link copied to clipboard
inline fun <S : IState> IState.findState(recursive: Boolean = true): S?

Find state by type. Search by type is suitable when using own state subclasses that usually do not have a name. Only on state should match the type or exception will be thrown.

fun IState.findState(name: String, recursive: Boolean = true): IState?

Get state by name. This might be used to start listening to state after state machine setup.

fun <S : IState> IState.findState(class: KClass<S>, recursive: Boolean = true): S?

For internal use. Workaround that Kotlin does not support recursive inline functions.

Link copied to clipboard

Find transition by Event type. This might be used to start listening to transition after state machine setup.

Find transition by name. This might be used to start listening to transition after state machine setup.

Link copied to clipboard
fun IState.historyState(name: String? = null, defaultState: IState? = null, historyType: HistoryType = HistoryType.SHALLOW): DefaultHistoryState
Link copied to clipboard
inline fun <D : Any> IState.initialChoiceDataState(name: String? = null, noinline choiceAction: suspend EventAndArgument<*>.() -> DataState<D>): DefaultChoiceDataState<D>
Link copied to clipboard
fun IState.initialChoiceState(name: String? = null, choiceAction: suspend EventAndArgument<*>.() -> State): DefaultChoiceState
Link copied to clipboard
inline fun <D : Any> IState.initialDataState(name: String? = null, defaultData: D, childMode: ChildMode = ChildMode.EXCLUSIVE, dataExtractor: DataExtractor<D> = defaultDataExtractor(), noinline init: StateBlock<DataState<D>>? = null): DefaultDataState<D>
Link copied to clipboard
inline fun <D : Any> IState.initialFinalDataState(name: String? = null, defaultData: D? = null, dataExtractor: DataExtractor<D> = defaultDataExtractor(), noinline init: StateBlock<FinalDataState<D>>? = null): DefaultFinalDataState<D>
Link copied to clipboard
Link copied to clipboard
fun IState.initialState(name: String? = null, childMode: ChildMode = ChildMode.EXCLUSIVE, init: StateBlock<State>? = null): DefaultState

A shortcut for state and IState.setInitialState calls

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
suspend fun IState.log(lazyMessage: () -> String)
Link copied to clipboard
Link copied to clipboard
open suspend fun onCleanup()

Called when state is sequentially used on multiple machine instances, to perform cleanup steps.

Link copied to clipboard
open suspend fun onStopped()

Called when machine is stopped, to perform cleanup steps.

Link copied to clipboard
abstract fun removeListener(listener: IState.Listener)
Link copied to clipboard
Link copied to clipboard
inline fun <S : IState> IState.requireState(recursive: Boolean = true): S

Require state by type

fun IState.requireState(name: String, recursive: Boolean = true): IState
Link copied to clipboard

Require transition by Event type

Link copied to clipboard
abstract fun setInitialState(state: IState)

Initial child state is required if child mode is ChildMode.EXCLUSIVE and a state has children

Link copied to clipboard
fun IState.state(name: String? = null, childMode: ChildMode = ChildMode.EXCLUSIVE, init: StateBlock<State>? = null): DefaultState
Link copied to clipboard
inline fun <E : Event> TransitionStateApi.transition(name: String? = null, block: UnitGuardedTransitionBuilder<E>.() -> Unit): Transition<E>

Creates transition. You can specify guard function. Such guarded transition is triggered only when guard function returns true.

inline fun <E : Event> TransitionStateApi.transition(name: String? = null, targetState: State? = null, type: TransitionType = LOCAL, metaInfo: MetaInfo? = null): Transition<E>

Shortcut overload for transition with an optional target state

Link copied to clipboard

Creates conditional transition. Caller should specify lambda which calculates TransitionDirection. For example target state may be different depending on some condition.

Link copied to clipboard

This is more powerful version of transition function. Here target state is a lambda which returns desired State. This allows to use lateinit state variables for recursively depending states and choose target state depending on application business logic.