Guest User

Untitled

a guest
Jul 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. @Scope
  2. @Retention(AnnotationRetention.RUNTIME)
  3. annotation class MyTestScope
  4.  
  5. class A {
  6. fun get() = 1
  7. }
  8.  
  9. @Module
  10. class TestModule {
  11. @Provides
  12. @MyTestScope
  13. fun provideA(): A {
  14. return A()
  15. }
  16. }
  17.  
  18. @MyTestScope
  19. @Component(dependencies = [AppComponent::class],
  20. modules = [TestModule::class])
  21. interface DependentComponent {
  22. @Component.Builder
  23. interface Builder {
  24. @BindsInstance
  25. fun appComponent(component: AppComponent): Builder
  26. fun build(): DependentComponent
  27. }
  28.  
  29. fun inject(application: Application)
  30. }
  31.  
  32. @Singleton
  33. @Component(modules = [
  34. AndroidInjectionModule::class,
  35. ActivityModule::class,
  36. // etc ....
  37. ])
  38. interface AppComponent {
  39. @Component.Builder
  40. interface Builder {
  41. @BindsInstance
  42. fun language(language: Language): Builder
  43. @BindsInstance
  44. fun appContext(appContext: Context): Builder
  45. fun build(): AppComponent
  46. }
  47.  
  48. fun inject(application: Application)
  49. }
Add Comment
Please, Sign In to add comment