launchTakeAndChangeState
fun launchTakeAndChangeState(context: CoroutineContext = coroutineContext, action: suspend (State) -> suspend () -> State): Job
Launches in a given CoroutineContext to change from the current State to a new State. This operation ensures atomic state changes.
Parameters
context
The CoroutineContext in which to use the state.
action
Function to determine the State to be transitioned to from the current State. If no state transition should occur, return KalugaState.remain
See also
fun <K : State> launchTakeAndChangeState(context: CoroutineContext = coroutineContext, remainIfStateNot: KClass<K>, action: suspend (K) -> suspend () -> State): Job
Launches in a given CoroutineContext to change from the current State to a new State. This operation ensures atomic state changes.
Parameters
context
The CoroutineContext in which to use the state.
remainIfStateNot
If the current state at the time of Action is not an instance of this class, the state will automatically remain.
action
Function to determine the State to be transitioned to from the current State. If no state transition should occur, return KalugaState.remain