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?