The Window boundary is not respect.
See original GitHub issueHi All,
I creating a library for communicate with REST endpoint. I have to buffer REST request and sent its together in the batch, but also I want to have a possibility to flush buffer.
Here is the snippet of my implementation:
PublishProcessor<Flowable<String>> flush = PublishProcessor.create();
PublishProcessor<String> restProcessor = PublishProcessor.create();
int count = 2;
int delay = 100;
TestScheduler scheduler = new TestScheduler();
Flowable<Flowable<String>> boundary = restProcessor.window(delay, TimeUnit.MILLISECONDS, scheduler, count, true)
.mergeWith(flush);
restProcessor
.window(boundary)
.concatMapSingle(Flowable::toList)
.filter(it -> !it.isEmpty())
.subscribe(strings -> System.out.println("emit REST call >>> " + strings));
The problem is that the restProcessor first emit a value with single element instead of two.
restProcessor.offer("1");
restProcessor.offer("2");
restProcessor.offer("3");
restProcessor.offer("4");
restProcessor.offer("5");
restProcessor.offer("6");
restProcessor.offer("7");
restProcessor.offer("8");
restProcessor.offer("9");
flush.offer(Flowable.just("flush"));
restProcessor.offer("10");
System.out.println("onComplete");
restProcessor.onComplete();
flush.onComplete();
Result
emit REST call >>> [1]
emit REST call >>> [2, 3]
emit REST call >>> [4, 5]
emit REST call >>> [6, 7]
emit REST call >>> [8, 9]
onComplete
emit REST call >>> [10]
I think that the result should be:
emit REST call >>> [1, 2]
emit REST call >>> [3, 4]
emit REST call >>> [5, 6]
emit REST call >>> [7, 8]
emit REST call >>> [9]
onComplete
emit REST call >>> [10]
The Junit test for reproduce is here (Gist)
RxJava version
io.reactivex.rxjava2:rxjava:2.2.4.
Java version
java version “1.8.0_152”
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
The Broken Windows Theory Applied to Boundaries & Self ...
You cannot negotiate with boundaries that directly impact you treating yourself with love, care, trust, and respect. They are your personal ...
Read more >Do You Need A Boundary Or A (Behavior) Window? - LinkedIn
The Behavior Window, part of the Gordon Model, defines problem ownership and responsibility. It's as simple as that. (It's not an act of...
Read more >The Importance Of Setting Healthy Boundaries - Forbes
Setting healthy boundaries is part of self-care and self-respect and should help form the base of your own personal leadership.
Read more >You Have a Window to Draw Your Boundary. Do It.
It's how you build respect for yourself and take back your power. It's how your sense of self and values get solidified over...
Read more >Flexbox child does not respect the boundaries of its parent
you can also use flex for image wrapper and you may set image in absolute position to avoid see it shrinking :
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Works as intended. What happens is that the boundary fires before the main sequence gets
2
, thus2
ends up in the subsequent window. You have to swap the order of the consumers to therestProcessor
via another processor:Why did you add that
observeOn
in the first place? If you need asynchrony, move it further away from the windowing logic.