trevjones
08/04/2020, 8:27 PMcombine(one, two, three) { 1, 2, 3 -> Triple(1,2,3) }.flatMapLatest { (1, 2, 3) -> ... }
is there a cleaner way built in to deal with that?louiscad
08/05/2020, 5:42 AMtrevjones
08/06/2020, 7:24 PMinline fun <T1, T2, T3, R> combineFlatLatest(
one: Flow<T1>,
two: Flow<T2>,
three: Flow<T3>,
crossinline combiner: (T1, T2, T3) -> Flow<R>
): Flow<R> {
return combine(one, two, three) { _one, _two, _three ->
arrayOf(_one, _two, _three)
}.flatMapLatest { elements ->
@Suppress("UNCHECKED_CAST")
combiner(
elements[0] as T1,
elements[1] as T2,
elements[2] as T3
)
}
}