AsyncStateMachineInstance

class AsyncStateMachineInstance<S, E, C, A, R>(context: C, val definition: AsyncStateMachineDefinition<S, E, C, A, R>, val coroutineScope: CoroutineScope, initialState: S? = null, initialExternalState: ExternalState<S>? = null)

Constructors

Link copied to clipboard
constructor(context: C, definition: AsyncStateMachineDefinition<S, E, C, A, R>, initialExternalState: ExternalState<S>, coroutineScope: CoroutineScope)

Create a state machine using a specific definition and a previous externalised state.

constructor(context: C, definition: AsyncStateMachineDefinition<S, E, C, A, R>, coroutineScope: CoroutineScope, initialState: S? = null, initialExternalState: ExternalState<S>? = null)

Properties

Link copied to clipboard
val coroutineScope: CoroutineScope

The initialState will be assigned to the currentState

Link copied to clipboard
Link copied to clipboard

The Immutable definition of the state machine.

Functions

Link copied to clipboard
fun allowed(includeDefault: Boolean = false): Set<E>

This function will provide the set of allowed events given a specific state. It isn't a guarantee that a subsequent transition will be successful since a guard may prevent a transition. Default state handlers are not considered.

Link copied to clipboard
fun eventAllowed(event: E, includeDefault: Boolean): Boolean

This function will return an indicator if the given event is allowed given the current state.

Link copied to clipboard

This function will provide the external state that can be use when creating the instance at a later time.

Link copied to clipboard
suspend fun sendEvent(event: E, arg: A? = null): R?

This function will process the on and advance the state machine according to the FSM definition.