is there a way to do this properly? ``` fir...
# coroutines
i
is there a way to do this properly?
Copy code
firstFlow.combine(secondFlow) { text: String, role: Role ->
            repository.getProcessList(role.apiParam, text)//returns new flow each time
        }.flatMapLatest {
            it
        }
m
that won’t do what you expect. Just make it a Pair in the combine lambda, and then in the flatMapLatest use your flow
firstFlow.combine(secondFlow) { text: String, role: Role -> role.apiParam to text }
.flatMapLatest { (apiParam, text) ->
repository.getProcessList(apiParam, text)
}
i
thank you, this looks better
j
Harder, but an interesting exercise - implement a
combineLatest
operator, and use it followed by
flatten
.
combineLatest
would combine the latest emissions of the source flows and switch to the latest flow returned by its
suspend
lambda parameter blob shrug.
🤔 1