This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DefaultAuthInteractor @Inject constructor( | |
private val checkUserRegisteredUseCase: CheckUserRegisteredUseCase, | |
private val trustedLoginUserUseCase: TrustedLoginUserUseCase | |
) : AuthInteractor { | |
/** | |
* See how AuthInteractor coordinates the work between use-cases. | |
*/ | |
override fun login(): Completable = | |
checkUserRegisteredUseCase.source() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrustedLoginUserUseCase @Inject constructor( | |
private val authTokenStorage: AuthTokenStorage, | |
private val repository: AuthRepository, | |
private val secureRandom: SecureRandom, | |
schedulersFactory: SchedulersFactory | |
) : CompletableUseCase(schedulersFactory) { | |
override fun sourceImpl(params: Params): Completable { | |
val pinCode = params.require<String>(PARAM_KEY_REG_PIN_CODE) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class GetStocksUseCase @Inject constructor( | |
private val repository: StockListRepository, | |
schedulersFactory: SchedulersFactory | |
) : SingleUseCase<List<Stock>>(schedulersFactory) { | |
override fun sourceImpl(params: Params): Single<List<Stock>> = | |
repository.stocks() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App : Application(), ApiContainer { | |
@Inject | |
@FeatureApis | |
lateinit var featuresMap: Map<Class<*>, @JvmSuppressWildcards Api> | |
@Suppress("Unchecked_Cast") | |
override fun <T> getFeature(key: Class<T>): T = | |
featuresMap[key] as T |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component( | |
modules = [ | |
CoreApiModule::class, | |
DataApiModule::class, | |
FeatureApiModule::class | |
] | |
) | |
interface AppComponent { | |
@FeatureApis |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
object CoreApiModule { | |
@Provides | |
@IntoMap | |
@ClassKey(NetworkCoreLibApi::class) | |
@CoreApis | |
fun networkApi(): Api = DaggerNetworkCoreLibComponent.factory().create() | |
@Provides |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
object DataApiModule { | |
@Provides | |
@IntoMap | |
@ClassKey(StockListDataApi::class) | |
@DataApis | |
fun stockListDataApi(@CoreApis coreApis: Map<Class<*>, @JvmSuppressWildcards Api>): Api = | |
DaggerStockListDataComponent.factory() | |
.create( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Module | |
object FeatureApiModule { | |
@Provides | |
@IntoMap | |
@ClassKey(StockListFeatureApi::class) | |
@FeatureApis | |
fun stockListFeatureApi( | |
@CoreApis coreApis: Map<Class<*>, @JvmSuppressWildcards Api>, | |
@DataApis dataApis: Map<Class<*>, @JvmSuppressWildcards Api> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App : Application(), ApiContainer { | |
@Inject | |
@FeatureApis | |
lateinit var featuresMap: Map<Class<*>, @JvmSuppressWildcards Api> | |
@Suppress("Unchecked_Cast") | |
override fun <T> getFeature(key: Class<T>): T = | |
featuresMap[key] as T | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface ApiContainer { | |
fun <T> getFeature(key: Class<T>): T | |
} | |
inline fun <reified T> ApiContainer.getFeature(): T = | |
getFeature(T::class.java) |