https://kotlinlang.org logo
Title
i

ildar.i [Android]

04/29/2022, 8:18 AM
is there a way to do this properly?
firstFlow.combine(secondFlow) { text: String, role: Role ->
            repository.getProcessList(role.apiParam, text)//returns new flow each time
        }.flatMapLatest {
            it
        }
m

myanmarking

04/29/2022, 8:27 AM
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

ildar.i [Android]

04/29/2022, 8:33 AM
thank you, this looks better
j

julian

04/29/2022, 5:18 PM
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