Olenyov Kirill
07/22/2020, 7:08 AMJavier
07/22/2020, 8:49 AMcombine
or combineTransform
flow functions. You should create a function or extension function to combine your resource flows easily.
fun <T1, T2, T3> Flow<Resource<T1>>.combine(resourceFlow: Flow<Resource<T2>): Flow<Resource<R3>>
Olenyov Kirill
07/22/2020, 9:06 AMJavier
07/22/2020, 9:30 AMJavier
07/22/2020, 9:32 AMwhen
which checks both resource states.Javier
07/22/2020, 9:35 AMwhen {
this is Error -> this
resource is Error -> resource
this is Success && resource is Success -> Success(success(this.data, resource.data))
this is Loading || resource is Loading -> Loading
else -> throw IllegalStateException("This state should not be possible")
}
Olenyov Kirill
07/22/2020, 9:40 AMMark Murphy
07/22/2020, 11:14 AMFlow
you mean Flow
from coroutines, you might consider asking in the #coroutines channel.