Almas Shagdarov
11/07/2019, 11:03 AMwbertan
11/07/2019, 11:09 AMinput.addTextChangedListener(object : TextWatcherAdapter() {
            override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
                viewModel.onInputUpdated(s?.toString() ?: "")
            }
        })
And in the `viewModel`:
fun onInputUpdated(text: String) {
        //Do stuff
    }
We usually also make the object : TextWatcherAdapter into a val in the Fragment to remove the text listener when it is destroyed.Almas Shagdarov
11/07/2019, 11:10 AMAlmas Shagdarov
11/07/2019, 11:11 AMwbertan
11/07/2019, 11:16 AMinit method, we have our own start method, so we can “control” when to start, etc.
Then it is straightforward, in the Fragment we listen for the live data, and after start, it will post the data and as the Fragment is listening, it will update the views.Almas Shagdarov
11/07/2019, 11:18 AMAlmas Shagdarov
11/07/2019, 11:18 AMAnastasia Finogenova
11/07/2019, 1:39 PMAnastasia Finogenova
11/07/2019, 1:40 PM