Kotlin coroutine flow example for Android button click event?
问题 I used to use Channel to send out click event from Anko View class to Activity class, however more and more Channel functions are marked as deprecated. So I wanted to start using Flow apis. I migrated code below: private val btnProduceChannel = Channel<Unit>() val btnChannel : ReceiveChannel<Unit> = btnProduceChannel // Anko button { onClick { btnProduceChannel.send(Unit) } } to: lateinit var btnFlow: Flow<Unit> private set button { btnFlow = flow { onClick { emit(Unit) } } } I have to mark