1

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:

but I have no idea how I can use it with Flow

General Grievance
  • 4,259
  • 21
  • 28
  • 43
iknow
  • 6,507
  • 10
  • 30
  • 55

0 Answers0