https://kotlinlang.org logo
#flow
Title
# flow
d

darkmoon_uk

12/21/2021, 3:11 PM
Is there no
flatMap-
family operator that ignores new upstream emissions while a mapping operation is being processed (i.e. mapped stream is not completed)? How could this be achieved? I don't want emissions buffered as with
concat
, but thrown away/ignored.
n

Nick Allen

12/21/2021, 3:56 PM
Use the
buffer
operator before
flatMap-
. I think you want
buffer(Channel.RENDEZVOUS, BufferOverflow.DROP_LATEST)
FYI,
flatMapConcat
doesn’t buffer anything. It’s the
Flow
you applied the operator on that is doing the buffering.
👍 1
d

darkmoon_uk

12/22/2021, 12:01 AM
Thanks @Nick Allen
n

Nick Allen

12/22/2021, 12:08 AM
I mixed up the BufferOverflow param that you want before. Just replaced
DROP_OLDEST
with
DROP_LATEST
in earlier comment.
3 Views