add Auth Component
This commit is contained in:
parent
d71fda5853
commit
9b85bcf562
|
|
@ -3,8 +3,8 @@ package ru.touchin.template.di
|
|||
import android.content.Context
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import javax.inject.Singleton
|
||||
import ru.touchin.template.App
|
||||
import ru.touchin.template.di.auth.AuthComponent
|
||||
import ru.touchin.template.di.modules.AppModule
|
||||
import ru.touchin.template.di.modules.NavigationModule
|
||||
import ru.touchin.template.di.modules.ViewModelModule
|
||||
|
|
@ -17,9 +17,11 @@ import ru.touchin.template.feature.SingleActivity
|
|||
NavigationModule::class
|
||||
]
|
||||
)
|
||||
@Singleton
|
||||
@AppScope
|
||||
interface AppComponent : SharedComponent {
|
||||
|
||||
fun authComponent(): AuthComponent.Builder
|
||||
|
||||
@Component.Builder
|
||||
interface Builder {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package ru.touchin.template.di
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
@Scope
|
||||
annotation class AppScope
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
package ru.touchin.template.di.auth
|
||||
|
||||
import dagger.Subcomponent
|
||||
import ru.touchin.template.feature.first.FirstFragment
|
||||
|
||||
@Subcomponent(modules = [AuthModule::class])
|
||||
@AuthScope
|
||||
interface AuthComponent {
|
||||
|
||||
@Subcomponent.Builder
|
||||
interface Builder {
|
||||
|
||||
fun build(): AuthComponent
|
||||
}
|
||||
|
||||
fun inject(entry: FirstFragment)
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package ru.touchin.template.di.auth
|
||||
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import ru.touchin.template.feature.second.SecondRepository
|
||||
import ru.touchin.template.feature.second.SecondRepositoryImpl
|
||||
|
||||
@Module
|
||||
class AuthModule {
|
||||
|
||||
@Provides
|
||||
@AuthScope
|
||||
internal fun providesSecondRepository(): SecondRepository {
|
||||
return SecondRepositoryImpl()
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package ru.touchin.template.di.auth
|
||||
|
||||
import javax.inject.Scope
|
||||
|
||||
@Scope
|
||||
annotation class AuthScope
|
||||
|
|
@ -1,11 +1,13 @@
|
|||
package ru.touchin.template.di.modules
|
||||
|
||||
import dagger.Module
|
||||
import ru.touchin.template.di.auth.AuthComponent
|
||||
|
||||
@Module(
|
||||
includes = [
|
||||
RepositoryModule::class,
|
||||
NetworkModule::class
|
||||
]
|
||||
],
|
||||
subcomponents = [AuthComponent::class]
|
||||
)
|
||||
class AppModule
|
||||
Loading…
Reference in New Issue