Skip to content

Commit

Permalink
documented Hilt Qualifiers for the app
Browse files Browse the repository at this point in the history
  • Loading branch information
myofficework000 committed Mar 1, 2024
1 parent dc1736b commit 465fc51
Showing 1 changed file with 83 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import com.example.jetpack_compose_all_in_one.features.random_fox.model.IRandomF
import com.example.jetpack_compose_all_in_one.features.random_fox.model.RandomFoxImpl
import com.example.jetpack_compose_all_in_one.features.tmdb_using_flows_paging3.tmdbapi.repository.IMovieRepository
import com.example.jetpack_compose_all_in_one.features.tmdb_using_flows_paging3.tmdbapi.repository.MovieRepository
import com.example.jetpack_compose_all_in_one.third_party_lib.currency_exchange.remote.repository.CurrencyIRepository
import com.example.jetpack_compose_all_in_one.third_party_lib.currency_exchange.remote.repository.CurrencyRepositoryImpl
import com.example.jetpack_compose_all_in_one.third_party_lib.airtel_api.repo.AirtelRepository
import com.example.jetpack_compose_all_in_one.third_party_lib.airtel_api.repo.AirtelRepositoryImpl
import com.example.jetpack_compose_all_in_one.third_party_lib.currency_exchange.remote.repository.CurrencyIRepository
import com.example.jetpack_compose_all_in_one.third_party_lib.currency_exchange.remote.repository.CurrencyRepositoryImpl
import com.example.jetpack_compose_all_in_one.third_party_lib.graph_ql_country_list.model.CountriesRepository
import com.example.jetpack_compose_all_in_one.third_party_lib.graph_ql_country_list.model.CountriesRepositoryImpl
import com.example.jetpack_compose_all_in_one.third_party_lib.paging3.repository.GitHubRepository
Expand All @@ -36,79 +36,155 @@ import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

/**
* Dagger module responsible for binding various repository implementations to their respective interfaces.
* This module is installed in the [SingletonComponent], ensuring that the provided instances are singleton-scoped.
*/
@Module
@InstallIn(SingletonComponent::class)
abstract class RepositoryModules {

/**
* Binds [MovieRepository] implementation to the [IMovieRepository] interface.
* This binding is annotated with [TMDBAPI] qualifier.
* @return an instance of [IMovieRepository].
*/
@Binds
@Singleton
@TMDBAPI
abstract fun bindMovieRepository(impl: MovieRepository): IMovieRepository

/**
* Binds [NewsRepository] implementation to the [INewsRepository] interface.
* This binding is annotated with [NewsAPI] qualifier.
* @return an instance of [INewsRepository].
*/
@Binds
@Singleton
@NewsAPI
abstract fun bindNewsRepository(impl: NewsRepository): INewsRepository

/**
* Binds [NewsApiRepositoryImpl] implementation to the [INewsApiRepository] interface.
* This binding is annotated with [NewsOrgAPI] qualifier.
* @return an instance of [INewsApiRepository].
*/
@Binds
@Singleton
@NewsOrgAPI
abstract fun bindNewsOrgApiRepository(impl: NewsApiRepositoryImpl) : INewsApiRepository
abstract fun bindNewsOrgApiRepository(impl: NewsApiRepositoryImpl): INewsApiRepository

/**
* Binds [DogRepository] implementation to the [IDogRepository] interface.
* This binding is annotated with [DogAPI] qualifier.
* @return an instance of [IDogRepository].
*/
@Binds
@Singleton
@DogAPI
abstract fun bindDogRepository(impl: DogRepository): IDogRepository

/**
* Binds [RandomDogRepository] implementation to the [IRandomDogRepository] interface.
* This binding is annotated with [RandomDogAPI] qualifier.
* @return an instance of [IRandomDogRepository].
*/
@Binds
@Singleton
@RandomDogAPI
abstract fun bindRandomDogRepository(impl: RandomDogRepository): IRandomDogRepository

/**
* Binds [DomainSearchRepository] implementation to the [IDomainSearchRepository] interface.
* @return an instance of [IDomainSearchRepository].
*/
@Binds
@Singleton
abstract fun bindDomainSearchRepository(impl: DomainSearchRepository): IDomainSearchRepository

/**
* Binds [RandomFoxImpl] implementation to the [IRandomFoxRepository] interface.
* This binding is annotated with [RandomFoxAPI] qualifier.
* @return an instance of [IRandomFoxRepository].
*/
@Binds
@Singleton
@RandomFoxAPI
abstract fun bindRandomFoxRepository(impl: RandomFoxImpl): IRandomFoxRepository

/**
* Binds [StripeRepositoryImpl] implementation to the [StripeRepository] interface.
* @return an instance of [StripeRepository].
*/
@Binds
@Singleton
abstract fun bindStripeRepository(impl: StripeRepositoryImpl): StripeRepository

/**
* Binds [PreferenceRepositoryImpl] implementation to the [PreferenceRepository] interface.
* @return an instance of [PreferenceRepository].
*/
@Binds
@Singleton
abstract fun bindPreferenceRepository(impl: PreferenceRepositoryImpl): PreferenceRepository

/**
* Binds [GitHubRepositoryImpl] implementation to the [GitHubRepository] interface.
* This binding is annotated with [GithubAPI] qualifier.
* @return an instance of [GitHubRepository].
*/
@Binds
@Singleton
@GithubAPI
abstract fun bindGithubRepository(impl: GitHubRepositoryImpl): GitHubRepository

/**
* Binds [CurrencyRepositoryImpl] implementation to the [CurrencyIRepository] interface.
* This binding is annotated with [CurrencyExchange] qualifier.
* @return an instance of [CurrencyIRepository].
*/
@Binds
@Singleton
@CurrencyExchange
abstract fun bindCurrencyRepository(impl: CurrencyRepositoryImpl) : CurrencyIRepository
abstract fun bindCurrencyRepository(impl: CurrencyRepositoryImpl): CurrencyIRepository

/**
* Binds [AirtelRepositoryImpl] implementation to the [AirtelRepository] interface.
* This binding is annotated with [AirtelAPI] qualifier.
* @return an instance of [AirtelRepository].
*/
@Binds
@Singleton
@AirtelAPI
abstract fun bindAirtelRepository(impl: AirtelRepositoryImpl): AirtelRepository

/**
* Binds [SpaceXLaunchesRepositoryImpl] implementation to the [SpaceXLaunchesRepository] interface.
* This binding is annotated with [SpaceXAPI] qualifier.
* @return an instance of [SpaceXLaunchesRepository].
*/
@Binds
@Singleton
@SpaceXAPI
abstract fun bindSpaceXLaunchesRepository(impl: SpaceXLaunchesRepositoryImpl): SpaceXLaunchesRepository

/**
* Binds [CountriesRepositoryImpl] implementation to the [CountriesRepository] interface.
* This binding is annotated with [CountryAPI] qualifier.
* @return an instance of [CountriesRepository].
*/
@Binds
@Singleton
@CountryAPI
abstract fun bindCountriesRepositoryRepository(impl: CountriesRepositoryImpl): CountriesRepository

/**
* Binds [RemoteNewsRepositoryImpl] implementation to the [RemoteNewRepository] interface.
* This binding is annotated with [MviNewsAPI] qualifier.
* @return an instance of [RemoteNewRepository].
*/
@Binds
@Singleton
@MviNewsAPI
abstract fun bindMviNewsRepository(impl:RemoteNewsRepositoryImpl) : RemoteNewRepository

}
abstract fun bindMviNewsRepository(impl: RemoteNewsRepositoryImpl): RemoteNewRepository
}

0 comments on commit 465fc51

Please sign in to comment.