Open DivS-15 opened 2 years ago
WorkManager should be initialized on-demand rather than when the app starts. WorkManager instance should be injected into the ViewModel.
WorkManager should be initialized on-demand rather than when the app starts.
WorkManager instance should be injected into the ViewModel.
workers.kt
object class WorkManagerInitializerModule (Hilt Module) in the di package (separate package for the WorkManagerSample app).
WorkManagerInitializerModule would implement Initializer< WorkManager > .
Description
Hilt should be used along with App Startup's Initializer interface to provide a WorkManager instance on first access.
Files that require refactoring so as to use @ HiltWorker
workers.kt
Classes to add, so that we can use dependency injection for WorkManager instance:
object class WorkManagerInitializerModule (Hilt Module) in the di package (separate package for the WorkManagerSample app).
WorkManagerInitializerModule would implement Initializer< WorkManager > .
Tasks