Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

delay on a range emits two at a time rather than everything at once #1724

Closed
dmgd opened this issue Oct 5, 2014 · 3 comments
Closed

delay on a range emits two at a time rather than everything at once #1724

dmgd opened this issue Oct 5, 2014 · 3 comments
Labels
Milestone

Comments

@dmgd
Copy link
Contributor

dmgd commented Oct 5, 2014

e.g.
range(1, 10).delay(1, SECONDS).subscribe(System.out::println) will result in two numbers being output each second for five seconds, rather than all ten after one second

sample unit test below. more tests and one way of fixing it (just using merge instead of concat) @ dmgd@29f0b80

@Test
public void testDelayEmitsEverything() {
    Observable<Integer> source = Observable.range(1, 5);
    Observable<Integer> delayed = source.delay(500L, TimeUnit.MILLISECONDS, scheduler);
    TestObserver<Integer> observer = new TestObserver<Integer>();
    delayed.subscribe(observer);
    scheduler.advanceTimeBy(500L, TimeUnit.MILLISECONDS);
    observer.assertReceivedOnNext(asList(1, 2, 3, 4, 5));
}
@benjchristensen benjchristensen added this to the 1.0 milestone Oct 7, 2014
@benjchristensen
Copy link
Member

Interesting ... so yes, merge almost gets the behavior we want, but it then allows concurrent execution and that means we can get things out of order which we can't allow.

Figuring out what needs to be done...

@headinthebox
Copy link
Contributor

Nice catch.

benjchristensen added a commit to benjchristensen/RxJava that referenced this issue Oct 10, 2014
Updated the implementations to support reactive pull backpressure.
Fixes ReactiveX#1724
@benjchristensen
Copy link
Member

Just merged a fix that I believe resolves this while making it work with backpressure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants