How to trigger ViewModel function when user input ...
# compose
r
How to trigger ViewModel function when user input changes on
TextField
? I'm implementing search screen and need to make network call based on input value. I'm using paging for response data and collecting as
LazyPagingItem
c
Create a function in your VM and reference it either this way
Copy code
TextField(value = viewModel.state.email, onValueChange = viewModel::onUpdateEmail)
or this way
Copy code
TextField(value = viewModel.state.email, onValueChange = { viewModel.onUpdateEmail(it) })
👍 1