Hi all. In the following code channel variable in ...
# coroutines
s
Hi all. In the following code channel variable in the statement this.channel.offer(it ?: “”) is highlighted with a warning “Non-applicable call for builder inference”.
Copy code
fun EditText.textChanges(): Flow<String> = callbackFlow {
    val textWatcher = textWatcher(afterText = {
        this.channel.offer(it ?: "")
    })
    this@textChanges.addTextChangedListener(textWatcher)
    awaitClose { this@textChanges.removeTextChangedListener(textWatcher) }
}

private fun textWatcher(
    beforeText: (String?) -> Unit = {},
    onText: (String?) -> Unit = {},
    afterText: (String?) -> Unit = {}
): TextWatcher {
    return object : TextWatcher {
        override fun afterTextChanged(s: Editable?) = afterText(s?.toString())
        override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = beforeText(s?.toString())
        override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = onText(s?.toString())
    }
}
Kotlin version: 1.3.50 Coroutines version: 1.3.0 IDE: Android Studio 3.5 I have two questions: 1. Why does this warning show up? 2. What does this warning stand for? Thanks in advance!