open class StateMachine<S, T : Any> : IStateMachine<S, T>
A basic state machine that is not thread safe.
StateMachine(initialState: S, vararg transitionRules: TransitionDef<S, out T>)StateMachine(initialState: S, transitions: List<TransitionDef<S, out T>>) |
var state: S
Current state of the machine. |
|
val transitionCallbacks: List<TransitionCallback<S, T>>
An immutable list of the currently registered callbacks. |
|
open val transitions: Set<KClass<out T>>
Transitions available to the current state. |
fun registerCallback(transitionCallback: TransitionCallback<S, T>): Boolean
Register a callback for state transition updates. |
|
open fun transition(transition: T): Unit
Transition the machine. |
|
open fun transitionsTo(targetState: S): Set<KClass<out T>>
Get the transition required to move to a given state. |
|
fun unregisterCallback(transitionCallback: TransitionCallback<S, T>): Boolean
Unregister a callback from state transition updates. |
fun <F, T : Any> transition(oldState: F, transition: KClass<T>, newState: F): TransitionDef<F, T> |