joakim
03/07/2021, 8:55 PMwasyl
03/07/2021, 9:27 PMflatMap
? Although network requests would usually return just a single value so maybe you can just use suspend fun
?joakim
03/07/2021, 9:37 PMwasyl
03/07/2021, 9:39 PMval firstResponse = api.firstRequest()
return api.secondRequest(firstResponse.id)
would work fine. If you need flows for some reason, then I think
api.firstRequest()
.flatMap { api.secondRequest(it.id) }
is the most idiomatic wayjoakim
03/07/2021, 9:41 PMsuspend fun execute(input) : Flow<Output> {
return flow {
repo1.getdata1.collect {
repo2.getData2.collect {
emit(CombinedData())
}
}
}
}
wasyl
03/07/2021, 10:25 PMcombine(flow1, flow2) { result1, result2 -> }
treatmaster
03/08/2021, 2:18 AM