Android should you really use by Lazy in ViewModel as per Docs?
This Android doc shows following code:
class MyViewModel : ViewModel() {
private val users: MutableLiveData by lazy {
MutableLiveData().also {
loadUsers()
}
}
fun getUsers(): LiveData {
return users
}
private fun loadUsers() {
// Do an asynchronous operation to fetch users.
}
}
and I'm wondering if it is really correct to use by lazy or...