Is it right to bind ViewModel to a service?

I started using Architecture components in my application, and I'm still learning how to use it.

In my application, I have an Activity showing different fragments in sequence. In some of them, I need to contact the background service to receive data from external BLE sensors. Since I need to interact with the service in more than one snippet, I wonder if the ViewModel is the right place to create the binding. I looked around , but I did not find the answer.

Are there any issues with service binding inside the ViewModel?

+4
source share
1 answer

Android ViewModels.

Google Developers : ViewModels LiveData: + AntiPatterns

ViewModels Android. , . thumb - , . * ViewModels ( android.arch. *). .

ViewModels ( ) Android

0

Source: https://habr.com/ru/post/1691982/


All Articles