This file contains 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
// Non-nullable to Non-nullable | |
interface ListMapper<I, O>: Mapper<List<I>, List<O>> | |
class ListMapperImpl<I, O>( | |
private val mapper: Mapper<I, O> | |
) : ListMapper<I, O> { | |
override fun map(input: List<I>): List<O> { | |
return input.map { mapper.map(it) } | |
} | |
} |
This file contains 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 FakePreferences : SharedPreferences { | |
private val map: MutableMap<String, Any?> = mutableMapOf() | |
private val listeners: MutableList<SharedPreferences.OnSharedPreferenceChangeListener> = mutableListOf() | |
override fun getAll(): MutableMap<String, *> = map | |
override fun getString(key: String, default: String?): String? = map[key] as String? ?: default | |
@Suppress("UNCHECKED_CAST") | |
override fun getStringSet(key: String, default: MutableSet<String>?): MutableSet<String>? = |
This file contains 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
data class SomeModel(val id: String, val name: String) | |
interface SomeModelRepository { | |
suspend fun getSomeModels(): Answer<List<SomeModel>, String> | |
} | |
fun interface GetSomeModelUseCase : suspend () -> Answer<List<SomeModel>, String> | |
class SomeViewModel(private val getSomeModelUseCase: GetSomeModelUseCase) : ViewModel() { | |
fun load() { |
This file contains 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
data class SomeModel(val id: String, val name: String) | |
interface SomeModelRepository { | |
suspend fun getSomeModels(): Answer<List<SomeModel>, String> | |
} | |
typealias GetSomeModelUseCase = suspend () -> Answer<List<SomeModel>, String> | |
class SomeViewModel(private val getSomeModelUseCase: GetSomeModelUseCase) : ViewModel() { | |
fun load() { |
This file contains 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
data class SomeModel(val id: String, val name: String) | |
interface SomeModelRepository { | |
suspend fun getSomeModels(): Answer<List<SomeModel>, String> | |
} | |
interface GetSomeModelUseCase { | |
suspend operator fun invoke(): Answer<List<SomeModel>, String> | |
} |
This file contains 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
data class SomeModel(val id: String, val name: String) | |
interface SomeModelRepository { | |
suspend fun getSomeModels(): Answer<List<SomeModel>, String> | |
} | |
class SomeViewModel(private val someModelRepository: SomeModelRepository) : ViewModel() { | |
fun load() { | |
viewModelScope.launch { | |
val result = someModelRepository.getSomeModels() |
This file contains 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
abstract class Employee { | |
abstract fun getSalary(): String | |
abstract fun getLineManager(): Employee | |
} | |
class SeniorAndroidDeveloper( | |
private val leadAndroidDeveloper: LeadAndroidDeveloper |
This file contains 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 FPGetTransactionUseCaseFactory( | |
private val userRepository: UserRepository, | |
private val transactionRepository: TransactionRepository | |
) { | |
fun makeGetTransactionsUseCase(): GetTransactionsUseCase { | |
return { | |
getTransactions( | |
userRepository::getUser, | |
transactionRepository |
This file contains 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 MyDaggerModule { | |
@Provides | |
fun provideGetTransactionsUseCase( | |
private val userRepository: UserRepository, | |
private val transactionRepository: TransactionRepository | |
): GetTransactionsUseCase { | |
return { | |
getTransactions( | |
userRepository::getUser, |
This file contains 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 GetTransactionsUseCase { | |
operator fun invoke(): Single<SimpleResult<List<Transaction>>> | |
} |
NewerOlder