Package-level declarations

Types

Link copied to clipboard

Allows to mutate some properties, which is necessary during setup, before machine is started Those properties are not passed through StateMachine's constructor to make DSL syntax more nice and readable.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
interface StateMachine : State
Link copied to clipboard

Functions

Link copied to clipboard
fun createStdLibStateMachine(name: String? = null, childMode: ChildMode = ChildMode.EXCLUSIVE, start: Boolean = true, creationArguments: CreationArguments = buildCreationArguments {}, init: suspend BuildingStateMachine.() -> Unit): StateMachine

Factory method for creating StateMachine. Suspendable code will be called via Kotlin Standard library (without Kotlin Coroutines library support).

Link copied to clipboard
suspend fun StateMachine.destroy(stop: Boolean = true)

Destroys machine structure clearing all listeners, states etc. This a terminal operation, means that machine cannot be used anymore.

Link copied to clipboard

Blocking analog of destroy

Link copied to clipboard
inline fun StateMachine.onDestroyed(crossinline block: suspend StateMachine.() -> Unit): StateMachine.Listener
Link copied to clipboard
inline fun StateMachine.onStarted(crossinline block: suspend StateMachine.(TransitionParams<*>) -> Unit): StateMachine.Listener
Link copied to clipboard
Link copied to clipboard
inline fun StateMachine.onStateExit(crossinline block: suspend StateMachine.(IState, TransitionParams<*>) -> Unit): StateMachine.Listener
Link copied to clipboard
Link copied to clipboard
inline fun StateMachine.onStopped(crossinline block: suspend StateMachine.() -> Unit): StateMachine.Listener
Link copied to clipboard
inline fun StateMachine.onTransitionComplete(crossinline block: suspend StateMachine.(activeStates: Set<IState>, TransitionParams<*>) -> Unit): StateMachine.Listener
Link copied to clipboard
Link copied to clipboard

Blocking analog of StateMachine.processEvent which can be called from usual (not suspendable) code.

Link copied to clipboard
suspend fun StateMachine.restart(argument: Any? = null)

Shortcut for StateMachine.stopBlocking and StateMachine.start sequence calls

Link copied to clipboard
fun StateMachine.restartBlocking(argument: Any? = null)
Link copied to clipboard
fun StateMachine.startBlocking(argument: Any? = null)
Link copied to clipboard
suspend fun StateMachine.stop()

Suspendable stopBlocking analog. Should be preferred especially if called from machine notifications.

Link copied to clipboard

Forces state machine to stop Warning: calling this function from notification callback may cause deadlock if you are using single threaded coroutineContext, so stop should be preferred.

Link copied to clipboard

Returns StateMachine.IgnoredEventHandler implementation that throws exception. This might be useful if you want to control that all events are handled (not skipped) by your StateMachine.

Link copied to clipboard

Returns StateMachine.PendingEventHandler implementation that throws exception. This is an old default behaviour.

Link copied to clipboard
suspend fun StateMachine.undo(argument: Any? = null): ProcessingResult

Rolls back transition (usually it is navigating machine to previous state). Previous states are stored in a stack, so this method mey be called multiple times if needed. This function has same effect as alternative syntax processEvent(UndoEvent), but throws if undo feature is not enabled.

Link copied to clipboard

Blocking analog of undo