These are chat archives for ReactiveX/RxJava

25th
Oct 2018
Yannick Lecaillez
@ylecaillez
Oct 25 2018 07:29
@akarnokd thank you so much for your reactivity !
Yannick Lecaillez
@ylecaillez
Oct 25 2018 07:36
Regarding your comment "The Reactive Streams specification also disallows synchronous cancellation after the terminal event anyway."
Where is it specified ? I was not able to find it.
Helder Sousa
@htmsousa
Oct 25 2018 08:19
Hi guys
Helder Sousa
@htmsousa
Oct 25 2018 08:34

I'm struggling to find an example where we can use Flowable.window(boundaryIndicatorSupplier). My goal is to create windows with groups of elements with same id.
Example:

Flowable.just(new MyObject(1, "X"), new MyObject(1, "Y"), new MyObject(1, "Z"), new MyObject(2, "A"), new MyObject(2, "B")
      .window( <boundary to create new window when MyObject changes from 1 to 2>)

(note, I want to do this in sorted flowables where I know when a "group" ends/starts (id changes from one value to the next))

any ideas?
Yannick Lecaillez
@ylecaillez
Oct 25 2018 09:45
@htmsousa not sure to understand what you want to achieve. Maybe are you looking for groupBy() ?
Helder Sousa
@htmsousa
Oct 25 2018 10:43
groupby will cache all items in memory
Yannick Lecaillez
@ylecaillez
Oct 25 2018 12:22
I think groupBy() respect backpressure so i don't see why it would cache everything ?
as far I understood, the "onComplete" of each Flowable created by "groupBy" won't be called until the "onComplete" of original flowable is called
Helder Sousa
@htmsousa
Oct 25 2018 13:50
if you want to convert each group into a List<Shape>, it means that all groups would have to keep all elements in memory until the onComplete operations are done
assuming the original Flowable is sorted, I think the window(boundary) would be able to create one list at a time, when the boundary condition is valid
I need something like this
window
but where each window will have any number of elements, determined by the boundary condition
Yannick Lecaillez
@ylecaillez
Oct 25 2018 15:13
i see, you know when you receive object 2 that upstream is done with object 1 and so on ... Is that right ?
Helder Sousa
@htmsousa
Oct 25 2018 16:16
correct
the boundary function in window should allow to implement this behaviour, but I'm not sure how
Helder Sousa
@htmsousa
Oct 25 2018 16:24
in theory, I could get away with this FlowableTransformers.bufferWhile(Predicate) if I keep track of previous element to be able to use in the predicate, but doesn't look the right way