Skip to content
This repository was archived by the owner on Jan 10, 2025. It is now read-only.
This repository was archived by the owner on Jan 10, 2025. It is now read-only.

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

Open
@DivS-15

Description

@DivS-15

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions