Wait for channel close
I have a channel that I only use to convey that a connection was closed. I figured a Unit channel which I then close on disconnect would be the most appropriate. Simplified example:
class Connection {
val disconnect = Channel(1, BufferOverflow.DROP_LATEST)
fun connect() {
backingConnection.disconnectCallback = {
disconnect.close()
}
backingConnection.connect()
}
}
Now the question is how to wait for this channel to close. Here are two options, both look a bit...