Skip to content

Instantly share code, notes, and snippets.

@ericntd
Created January 6, 2022 20:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericntd/d9d52b6d86dbf4d42650322fbe5340f1 to your computer and use it in GitHub Desktop.
Save ericntd/d9d52b6d86dbf4d42650322fbe5340f1 to your computer and use it in GitHub Desktop.
Dependency instead of Module example
@DependencyHolder
class CatDependencyHolder {
@Provides
@AppScope
fun retrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
}
@Provides
@AppScope
fun catApi(retrofit: Retrofit): CatApi =
retrofit.create(CatApi::class.java);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment