Hi guys! Does Moko support `SharedViewModel`in androidApp? Consider the situation when an
activity
holds a
fragment
, and I would like to invoke a method of the
activity viewmodel
in one of the
fragment
.
Copy code
private val viewModel: lISTViewModel by activityViewModels()
-----------
There is a
getViewModel
function in
ViewModelFactory
, but I don’t know how to use it.🥲
-----------
I can simply do
activity.viewmodel
in the fragment, so probably
sharedViewModel
is unnecessary.
a
alex009
08/17/2021, 6:02 AM
hi!
yes, you can use shared view model. with moko viewmodels you can do all that you do with android viewmodels, because moko viewmodel is subclass of android viewmodel.
alex009
08/17/2021, 6:04 AM
getViewModel
is additional function, you can ignore it and do viewmodel inject like you do in regular android app.
or you can use