EventHandler

Handler for a specific event within a state.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
fun guard(condition: (state: S) -> Boolean)

Sets a simple guard condition based only on the state.

fun guard(condition: (state: S, event: E) -> Boolean)

Sets a guard condition that must be satisfied for the event to be handled.

Link copied to clipboard
fun sideEffect(effect: (state: S) -> Unit)

Adds a side effect that only uses the state.

fun sideEffect(effect: (state: S, event: E) -> Unit)

Adds a side effect to be executed when this event is handled.

Link copied to clipboard
fun stay()

Indicates that the state should remain unchanged.

Link copied to clipboard
fun transitionTo(newState: S)

Defines a transition to a new state.

fun transitionTo(transition: (currentState: S) -> S)

Defines a transition using a function of the current state.

Link copied to clipboard
fun transitionWith(transition: (currentState: S, event: E) -> S)

Defines a transition using both current state and event.