I've a socket that I transform the messages in a f...
# flow
t
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?
I fixed it like this, looks like it works:
Copy code
var firstFalseReceived = false
flow<Boolean> { }
    .first {
        if (!firstFalseReceived && !it) {
            firstFalseReceived = true
        }
        firstFalseReceived && it
    }
e
Copy code
flow
    .dropWhile { it }
    .first { it }