Sam
04/24/2025, 4:18 PMsuspend
in other places besides an ordinary coroutine. I just know there are tons more, though, so I'm really interested to hear what other uses people have found.
https://sam-cooper.medium.com/suspending-kotlin-beyond-coroutines-4c97543b9782Youssef Shoaib [MOD]
04/24/2025, 4:37 PMAdam S
04/24/2025, 9:28 PMCLOVIS
04/25/2025, 8:01 AMclass StateMachine {
private var currentState = State.Initial
fun next(action: Action) {
when (action) {
Action.A ->
Action.B ->
}
}
}
you can write
val StateMachine = stateMachine {
waitFor(Action.A)
// …
select {
onAction(Action.A) -> …
onAction(Action.B) -> …
}
}
It helps a lot with understanding complex state machines when some actions are allowed in only some situations.Sam
04/25/2025, 8:31 AMSam
04/25/2025, 8:31 AM