transitionToState

fun transitionToState(value: V, targetState: S): Result<V>

Attempts to transition the given value to the specified state.

This function will only succeed if there exists a transition that can take the value from its current state to the target state in a single step.

Return

A Result containing either the transitioned value or an error

Parameters

value

The value to transition

targetState

The state to transition to