0

I want to make 3 API calls. But 2 API calls must be asynchronous and the last one must be wait this results. And I want to write this in usecase so there is no viewmodelscope. I tried to write with zip but it can only create 2 API calls.

class UseCase @Inject constructor(private val repository: Repository) :
        UseCase<Unit, Triple<String, String, String>> {
        override fun invoke(input: Unit): Flow<Triple<String, String, String>> {
            return combine(
                repository.getFirst(),
                repository.getSecond(),
                repository.getThird()
            ) { first, second, third ->
                Triple(first, second, third)
            }
        }
    }

Is there any different flow method to create synchronous and async together? Or any suggestion?

General Grievance
  • 4,555
  • 31
  • 31
  • 45
6155031
  • 4,171
  • 6
  • 27
  • 56

0 Answers0