I want to make 2 simultaneous API calls in my app. Currently, in Screen (@Composable) I have the following logic:
val (one, setOne) = remember {
    mutableStateOf(
        viewModel.currentOne
    )
}
val (two, setTwo) = remember {
    mutableStateOf(
        viewModel.currentTwo
    )
}
fun initSearch()
{
    setOne(viewModel.call1())
    setTwo(viewModel.call2())
}
call1 and call2 looks like this:
fun call1(): Flow<String>? { /* */ }
fun call2(): Flow<String>? { /* */ }
Now when I run initSearch it only calls the first API request which is call1. If I change function order and call first call2 it doesn't call call1.
I found these questions:
- Multiple API calls Simultaneously and update UI as soon as the processing of the corresponding request finishes Android
- Multiple retrofit2 requests using Flowable in Kotlin
- How can I call multiple requests at the same time in Retrofit 2
but I have no idea how I can use it with Flow
 
    