hi, when using this pattern ```class LoginViewMode...
# compose
a
hi, when using this pattern
Copy code
class LoginViewModel : ViewModel() {

    val registeredUsers = mutableStateListOf<UIRegisteredUser>()
in the view model 1. Is there way to protect this registeredUsers list from updating the object values from other than view model ? I'm tryting to avoid accidental modification these values from out side view model, trying to keep vm as single source of truth.
a
you can use
private set
on it, that way only the LoginViewModel will be allowed to change it.
👍 1
a
If you expose the
mutableStateListOf
from the
ViewModel
as just a normal
List
instead of a
MutableList
, then anything outside of the
ViewModel
won’t be able to change the list.
1
Whoops, I didn’t read the next thread. Glad to see the same conclusion there 😄 .
🙂 1