Reputation: 128
I learn MVVM in android. I can't understand why never mention services? Now my app looks like activity <-> viewmodel <-> repository <-> dao. For example i want to synchronize date from Firebase every 4 hours. Where i should check time and load data?
Upvotes: 4
Views: 546
Reputation: 2746
You can user the latest android architecture component
WorkManager
to schedule your job every 4 hours and sync data with firebase.
As of to your confusion, ViewModel can contain the business logic, But again these can always be tweak as per our need, for example, if you need to do UI operations from the service you might have to bind the service to activity, in that case the code will direclty be written into activity or so.
Upvotes: 1