Hi, I'm coming to coroutines from RxJs. And I'm lo...
# coroutines
j
Hi, I'm coming to coroutines from RxJs. And I'm looking for the equivalent of
switchMap
where showing search results while the user is typing. And I want to cancel all the previous requests to the server, just have the last one. In RxJs you use
switchMap
for that. What's the coroutine equivalent?
p
to
concatMap
you can:
Copy code
while(true) {
   userTypes.awaitFirst() //suspend fun
   showResult()
}
but
switchMap
might require launching coroutine in parallel and keeping reference to job to cancel it.
j
I think
concatMap
would wait for the previous result. But I don't want to do that: if there's a new event I want to cancel processing of the previous.
It should be in 1.2.1
👍 2
j
I didn't see it. I guess I overlooked something. Let me check.
I found it. Tx Simon!
s
Happy to help 🙂