Skip to content

[chore]: Migrate Architecture to Dependency Injection (Hilt) #3

Description

@Thunder-Blaze

Problem Description

The app relies on manual dependency injection. As the app scales, this manual wiring creates boilerplate and makes testing difficult.

Expected Solution

Refactor the codebase to use Dagger-Hilt for automated dependency injection.

Steps to Reproduce

  1. Check StocksActivity.kt and StockViewModelProviderFactory.kt to see manual repository passing.

Proposed Fix

Add Hilt Gradle plugins. Annotate the application with @HiltAndroidApp. Create a di/AppModule.kt to provide singletons of Room and Retrofit. Update ViewModels with @HiltViewModel and inject them into Fragments using by viewModels().

Concerned Files

  • build.gradle.kts
  • StocksApplication.kt
  • AppModule.kt (new)
  • All ViewModels and Fragments

Acceptance Criteria

  • StockViewModelProviderFactory is completely deleted from the project.
  • ViewModels are injected natively.
  • The app compiles and runs perfectly using Hilt injection.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestexceptionally hardReimplementation or rewriting certain modules of large scale projects

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions