SHARE
TWEET

Untitled

a guest Jun 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @Module
  2. class RepositoryModule {
  3.     @Provides
  4.     fun provideRepository(sharedPrefs: SharedPrefs.Companion, myApi: MyAPI) : Repository {
  5.         return Repository(sharedPrefs, myApi)
  6.     }
  7.  
  8.     @Provides
  9.     fun provideSharedPrefs() : SharedPrefs.Companion {
  10.         return SharedPrefs
  11.     }
  12. }
  13.  
  14. @Module
  15. class MyAPIModule {
  16.     @Provides
  17.     @Reusable
  18.     fun provideRetrofit(): MyAPI {
  19.         return Retrofit.Builder()
  20.             .baseUrl(BASE_URL)
  21.  
  22.    .addCallAdapterFactory(RxJava2CallAdapterFactory.createWithScheduler(Schedulers.io()))
  23.             .build()
  24.             .create(MyAPI::class.java)
  25.     }
  26. }
  27.      
  28. @Singleton
  29. @Component(modules = [(SharedPrefsModule::class), (MyAPIModule::class)])
  30. interface RepositoryComponent {
  31.     fun inject(repository: Repository)
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top