https://kotlinlang.org logo
#rx
Title
# rx
u

ubu

06/07/2019, 10:31 AM
Hi there. I'm looking for a way to collect `Observable`'s emissions in bundles of data, some sort of history of the last values. I know it sound like
buffer()
operator, but I just can't get it right. When having
A
,
B
,
C
,
D
,
E
,
F
emitted one after another with some delay, I would like to have an
Observable
emitting:
[A]
,
[A, B]
,
[A,B,C]
,
[B, C, D]
,
[C, D, E]
,
[D, E, F]
. We are only interested in last values, so I suppose, we could use here a
Flowable
. Thanks.
g

gsala

06/07/2019, 12:07 PM
You could use
.scan
and use some kind of queue/stack structure like
Deque
as the accumulator
👍 2
u

ubu

06/07/2019, 9:02 PM
thanks
a

alexsullivan114

06/18/2019, 3:41 PM
I've had to implement this multiple times unfortunately. Really what you're looking for is
combineLatest
but that emits a tuple or whatever with null values until every stream has emitted