Ive Vasiljevic
07/24/2019, 3:30 PMObject
or Class
Marko Mitic
07/24/2019, 3:37 PMursus
07/24/2019, 4:47 PMobject
pavi2410
07/24/2019, 5:44 PMclass MyRepository(private val apiService: ApiService) {
fun getMyStuff() = apiCall { apiService.getMyStuff() }
private fun <T> apiCall(call: suspend () -> Response<ResponseWrapper<T>>) = liveData {
emit(Result.Loading)
try {
val response = call()
if (response.isSuccessful) {
response.body()?.let {
if (it.success)
emit(Result.Success(it.data))
else
emit(Result.Error(it.message))
}
}
} catch (e: Exception) {
emit(Result.Error())
}
}
}
Marko Mitic
07/24/2019, 6:34 PMgildor
07/25/2019, 2:35 AMobject
with business logic become a problem for testability and modularization
It’s usually just a matter of time when it rewritten with proper interface/class and DIJoan Colmenero
07/25/2019, 2:37 PMpavi2410
07/25/2019, 2:40 PM