DataEvent not getting transitioned? #84
-
I've got two child states with parallel state machines, roughly corresponding to: state("connected") {
onEntry {
val incomingChannel = Channel<ByteArray>(10)
connectOutgoingDataTo(incomingChannel)
readerScope.launch {
incomingChannel.consume {
consumeAsFlow().collect {
Timber.tag("StateMachine").i { "Got some data: ${it.dump()}" }
machine.processEvent(IncomingBleMessage(it.toList()))
}
}
}
}
suspend fun ping(): ParsingState.ParsingSuccessful {
return suspendCancellableCoroutine { continuation ->
readerScope.launch {
sendToExternal()
}
}
}
state("ble") {
addInitialState(CommandStates.Waiting) {
transition<IncomingBleMessage> {
onTriggered {
val value = it.event.data
Timber.tag("StateMachine").d { "Got triggered with $value" }
// ... do some stuff with it
}
}
}
}
state("card") {
addInitialState(ReaderStates.CardScanRequested) {
onEntry {
val pong = ping()
// do something with it
}
}
}
}
data class IncomingBleMessage(override val data: List<Byte>): DataEvent<List<Byte>> Now I'm getting the data back from the ping:
but then it doesn't get fed into the state machine properly:
... where it basically just gets stuck, no more action happening. I'd expect it to advance at least to the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! What is the purpose of "queued event" message got printed when StateMachine receives new event while being processing the previous one. So looks that previous event processing is not complete or blocked with something. |
Beta Was this translation helpful? Give feedback.
Hi!
What is the purpose of
suspendCancellableCoroutine
here, I don't see where it resumes?"queued event" message got printed when StateMachine receives new event while being processing the previous one. So looks that previous event processing is not complete or blocked with something.