Android MutableState observe changes in ViewModel

Viewed 1483

Is it possible to observe changes in MutabeState from ViewModel? Obviously, all changes made to MutableState will cause re-composition in Composable. But is it possible to observe changes made by composable to MutableState from ViewModel?

In example: let's say we have input text from user which value is stored in MutableState in ViewModel. When user enters, say, 6 characters, we want to trigger an action in ViewModel. Or verify input on every character. We can do this using MutableStateFlow or Channel and collecting values in ViewModel's init. But is it possible using only MutableState? Or what is the best way to achieve this behavior?

0 Answers
Related