https://kotlinlang.org logo
#coroutines
Title
# coroutines
e

elizarov

02/27/2018, 7:03 PM
That just burns CPU while it waits. Are you sure you want that?
j

Joe

02/27/2018, 9:01 PM
I definitely don’t. And with @bj0’s suggestion, I’m using this instead (which seems to do the trick):
Copy code
suspend fun <T> ConflatedBroadcastChannel<T>.valueOrWait(): T {
    consume {
        return this.first()
    }
}
I originally misunderstood what
consume
was doing, which is why I avoided it.
2 Views