Is it correct to bind a ViewModel to a Service? Is it correct to bind a ViewModel to a Service? android android

Is it correct to bind a ViewModel to a Service?


It is not advisable to use Android framework classes inside ViewModels.

Here is the link on Google Developers blog post with the detailed explanation: ViewModels and LiveData: Patterns + AntiPatterns

Ideally, ViewModels shouldn’t know anything about Android. This improves testability, leak safety and modularity. A general rule of thumb is to make sure there are no android.* imports in your ViewModels (with exceptions like android.arch.*). The same applies to presenters.

Don’t let ViewModels (and Presenters) know about Android framework classes