Skip to content

Operator: throttleFirst #367

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

Closed

Conversation

benjchristensen
Copy link
Member

Another take on throttle … this delivers the first value in each window.

@benjchristensen
Copy link
Member Author

This will throttle to the first value received in each window.

        PublishSubject<Integer> o = PublishSubject.create();
        o.throttleFirst(500, TimeUnit.MILLISECONDS, s).subscribe(observer);

        // send events with simulated time increments
        s.advanceTimeTo(0, TimeUnit.MILLISECONDS);
        o.onNext(1); // deliver
        o.onNext(2); // skip
        s.advanceTimeTo(501, TimeUnit.MILLISECONDS);
        o.onNext(3); // deliver
        s.advanceTimeTo(600, TimeUnit.MILLISECONDS);
        o.onNext(4); // skip
        s.advanceTimeTo(700, TimeUnit.MILLISECONDS);
        o.onNext(5); // skip
        o.onNext(6); // skip
        s.advanceTimeTo(1001, TimeUnit.MILLISECONDS);
        o.onNext(7); // deliver
        s.advanceTimeTo(1501, TimeUnit.MILLISECONDS);
        o.onCompleted();

Compare with #366 and #365

Another take on `throttle` … this delivers the first value in each window.
@cloudbees-pull-request-builder

RxJava-pull-requests #260 SUCCESS
This pull request looks good

@benjchristensen
Copy link
Member Author

Javadoc:

Throttles to first value in each window.

This was referenced Sep 10, 2013
@benjchristensen
Copy link
Member Author

I have submitted 3 separate pull requests with different variants of throttle. I would appreciate feedback on them:

  • is the name and javadoc descriptive?
  • does the throttling strategy make sense?

Variants are:

@cloudbees-pull-request-builder

RxJava-pull-requests #261 SUCCESS
This pull request looks good

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

Successfully merging this pull request may close these issues.

2 participants