TransitionStateApi

Helper interface for IState to keep transitions logic separately.

Inheritors

Properties

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

Functions

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

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

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

Require transition by Event type

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.