I am building an Android App using MVVM and DataBinding. And I have a function inside my ViewModel that starts an Activity. Is it okay to have an onClick call inside a ViewModel
That's absolutely perfect to put it inside ViewModel
, however you need to set your ViewModel
from Activity
/Fragment
.
Here are some links you can follow to learn MVVM architecture.
Approaching Android with MVVM
Android MVVM
https://github.com/ivacf/archi
People-MVVM
MVVM on Android: What You Need to Know