I’m trying to use HILT to inject an implementation of a repository class into the UseCase class (the interface lives in the
domain
module, and the implementation in the
repository
module with the
repository
module depending on the
domain
one) but receiving an error when building the app:
DomainModule.kt - lives into
:domain
module
@Module
@InstallIn(SingletonComponent::class)
object DomainModule {
@Provides
fun provideGetUpcomingLaunchesUseCase(repository: SpaceHubRepository): GetUpcomingLaunchesUseCase {
return GetUpcomingLaunchesUseCaseImpl(repository)
}
}
SpaceHubRepository.kt - lives into:
:domain
module
interface SpaceHubRepository {
suspend fun getUpcomingLaunches(): Flow<List<Launch>>
}
RepositoryModule.kt - lives into
:repository
module
@Module
@InstallIn(SingletonComponent::class)
object RepositoryModule {
@Provides
fun provideRepository(
apiService: SpaceHubApiService,
launchMapper: LaunchMapper
): SpaceHubRepository {
return SpaceHubRepositoryImpl(apiService, launchMapper)
}
@Provides
fun provideLaunchMapper(): LaunchMapper = LaunchMapperImpl()
}