can I create ViewModel instances myself or do I ha...
# android
b
can I create ViewModel instances myself or do I have to do it with
by viewModels()
? tried to google
creating view model manually
and
kotlin by viewModels()
, couldn't find anything interesting
Copy code
We cannot directly create the object of the ViewModel as it would not be aware of the lifecyclerOwner.
­čĹŹ 1
k
@Bruno_ i guess we can use this
Copy code
val myViewModel = ViewModelProvider(this).get(MyViewModel::class.java)
b
it was more of a question
why
not
how
but thanks anyway