How would I combine usage of Android Services and ...
# android-architecture
i
How would I combine usage of Android Services and MVVM architecture? Should I start the service inside of my activity/fragment class and inside of View Model class listen when service has been connected? Or should I include repo that starts the service and sends data back to View Model observables ?
w
We handle the service in the repository layer- if the viewmodel subscribes to our livedata and finds the state to be unititalized, it kicks of the request.
Also, our services expose livedata that can be subscribed to
r
I don't think you need to keep any information about the start the service itself in the ViewModel layer just to maintain the integrity of the service. Just start it in the Activity or fragment. what triggers the start of it can be in the Viewmodel layer