DataEvent not getting transitioned? #84
Answered
by
nsk90
reactormonk
asked this question in
Q&A
|
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 |
Answered by
nsk90
Jan 20, 2024
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. |
1 reply
Answer selected by
reactormonk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
What is the purpose of
suspendCancellableCoroutinehere, 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.