Hi, is it good to use multiple `combine` in flows ...
# coroutines
k
Hi, is it good to use multiple
combine
in flows like below
Copy code
Firestore.getFlow1().combine(Firestore.getFlow2()) { f1, f2 -> Result(f1,f2)}
                .combine(Firestore.getFlow3()) { f3, result -> result.f3 = f3 }
                .collect { _liveData.value = it}
Here
Firesstore.get*
all are wrappers that converts firestores snapshow listeners to flow, so here i have to listen three flows and want to combine them . is it good to do like this or there is any other way also ?
l
You can use top-level combine and instantiate a
Triple
of the values from the three flows.
k
sorry i did not get it
@louiscad any example?
p
I'm not specialist, but maybe examples in https://kotlinlang.org/docs/reference/coroutines/flow.html#combine will helpful
👍 1
l
@Kulwinder Singh
combine(flow1, flow2, flow3) { value1, value2, value3 -> Triple(value1, value2, value3) }