Skip to content

Instantly share code, notes, and snippets.

@cp-hardik-p
Created December 21, 2021 11:54
Show Gist options
  • Select an option

  • Save cp-hardik-p/f099380b513b64eec5a3127f4a6d3d48 to your computer and use it in GitHub Desktop.

Select an option

Save cp-hardik-p/f099380b513b64eec5a3127f4a6d3d48 to your computer and use it in GitHub Desktop.
@InstallIn(SingletonComponent::class)
@Module
object NetworkModule {
@Singleton
@Provides
fun provideRetrofit(): Retrofit {
return Retrofit.Builder()
.baseUrl("https://howtodoandroid.com/apis/")
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.build()
}
@Singleton
@Provides
fun provideApiService(retrofit: Retrofit): ApiService {
return retrofit.create(ApiService::class.java)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment