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

koufa

11/23/2019, 1:25 PM
Hey I have a question about
callbackFlow
again. How would you review following code:
Copy code
fun TextView.onTextChange() = callbackFlow {
    val listener = addTextChangedListener { text ->
        if (text != null) {
            offer(text.toString())
        }
    }
    awaitClose { removeTextChangedListener(listener) }
}
d

Dominaezzz

11/23/2019, 2:46 PM
That looks fine.
d

dekans

11/23/2019, 7:07 PM
You may want to conflate it, in order to have the last value only
k

koufa

11/24/2019, 6:21 PM
Good idea it makes sense to have the last value in this usecase. Thank you
3 Views