Package-level declarations
Types
Base IState implementation for all states
Same as TransitionStateApi interface, for specialized DataState api.
The most common state
Pseudo-state that represents the child state that the parent state was in the last time before exited.
Marker interface. When StateMachine enters this state it finishes and does not accept events anymore. It is possible to use this interface to mark final state directly instead of subclassing DefaultFinalState
Defines state API for internal library usage. All states must implement this class. Unfortunately cannot use interface for this purpose. This is safe to cast any IState to InternalState by design for internal library implementation.
Base interface for all kind of states. Many additional methods implemented like extensions to keep this interface clean and minimalistic. States are mutable subject by the library design.
Pseudo state is a state that machine passes automatically without explicit event. It cannot be active.
Helper interface for IState to keep transitions logic separately.
Functions
Set of states that the state is currently in. Including state itself if selfIncluding is true. Internal states of nested machines are not included.
Helper dsl method for adding final states. This is exactly the same as simply call IState.addState but makes code more self expressive.
A shortcut for IState.addState and IState.setInitialState calls
Creates type safe argument transition to DataState.
Shortcut function for type safe target-less (self targeted) transition.
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.
Data transition, otherwise same as transitionOn
inline constructor function
inline constructor function
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.
Get state by name. This might be used to start listening to state after state machine setup.
For internal use. Workaround that Kotlin does not support recursive inline functions.
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.
A shortcut for state and IState.setInitialState calls
Triggers onChanged callback when condition "all passed states are active" changes
Triggers onChanged callback when condition "any of passed states is active" changes
Require transition by Event type
Creates transition. You can specify guard function. Such guarded transition is triggered only when guard function returns true.
Shortcut overload for transition with an optional target state
Creates conditional transition. Caller should specify lambda which calculates TransitionDirection. For example target state may be different depending on some condition.
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.