I've a socket that I transform the messages in a flow. I receive a lot of boolean messages. I want to wait until the first false and after that wait until the first true. I know I can wait like
flow.first { it }
but how to chain waiting the false first?
Tgo1014
04/28/2023, 1:22 PM
I fixed it like this, looks like it works:
Copy code
var firstFalseReceived = false
flow<Boolean> { }
.first {
if (!firstFalseReceived && !it) {
firstFalseReceived = true
}
firstFalseReceived && it
}