Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'WorkManagerSample' should use Hilt and App Startup library to initialize and provide WorkManager dependency #1059

Open
4 tasks done
DivS-15 opened this issue Jul 12, 2022 · 0 comments · May be fixed by #1060
Open
4 tasks done

Comments

@DivS-15
Copy link

DivS-15 commented Jul 12, 2022

Description

Hilt should be used along with App Startup's Initializer interface to provide a WorkManager instance on first access.

WorkManager should be initialized on-demand rather than when the app starts.

WorkManager instance should be injected into the ViewModel.

Files that require refactoring so as to use @ HiltWorker

workers.kt

Classes to add, so that we can use dependency injection for WorkManager instance:

  1. object class WorkManagerInitializerModule (Hilt Module) in the di package (separate package for the WorkManagerSample app).

  2. WorkManagerInitializerModule would implement Initializer< WorkManager > .

Tasks

  • Write a @ Provides method by overriding Initializer < WorkManager >'s create() method inside a Hilt Module.
  • consume the WorkManager dependency inside the viewmodel's constructor.
  • Refactor the worker classes to use @HiltWorker.
  • All relevant classes to use appropriate Hilt annotations.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
@DivS-15 and others