Is there an issue to track for `construction is no...
# announcements
e
Is there an issue to track for
construction is not yet supported in inline functions
compiler errors? Trying to do:
Copy code
private val beforeTextChangedStub: (s: CharSequence?, start: Int, count: Int, after: Int) -> Unit = { _, _, _, _ -> }
private val onTextChangedStub: (s: CharSequence?, start: Int, before: Int, count: Int) -> Unit = { _, _, _, _ -> }
private val afterTextChangedStub: (s: Editable?) -> Unit = {}

inline fun TextView.textChangedListener(
    beforeTextChanged: (s: CharSequence?, start: Int, count: Int, after: Int) -> Unit = beforeTextChangedStub,
    onTextChanged: (s: CharSequence?, start: Int, before: Int, count: Int) -> Unit = onTextChangedStub,
    afterTextChanged: (s: Editable?) -> Unit = {}
) {
  object : TextWatcher {
    override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) = beforeTextChanged(s, start, count, after)

    override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) = onTextChanged(s, start, before, count)

    override fun afterTextChanged(s: Editable?) = afterTextChanged(s)
  }.apply { addTextChangedListener(this) }
}