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

Operation throttleLast #365

Closed

Conversation

benjchristensen
Copy link
Member

Merge of #258

@cloudbees-pull-request-builder

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

@benjchristensen
Copy link
Member Author

NOTE: This implementation is modified to use window which differs from the original. It feels simpler but is not exactly the same as was contributed, nor do I think it's an exact match to Rx.Net.

As currently implemented this returns the last value of each window as opposed to restarting the time at each onNext. I'm playing with that implementation next.

I'm curious about when the different types of implementations may be more valuable than others.

@samuelgruetter
Copy link
Contributor

Great! Looking forward to having this operator :)

@benjchristensen
Copy link
Member Author

This will return the last value in each time window. It will always emit at least 1 value in each window.

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

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

Compare this with #366

@benjchristensen
Copy link
Member Author

Please review this behavior and let me know if it is accurate and if the name is explanatory.

@benjchristensen
Copy link
Member Author

Javadoc:

Throttles to last value in each window.

@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:

@DavidMGross
Copy link
Collaborator

Would you summarize for me how this differs from sample()?

On Tue, Sep 10, 2013 at 12:17 AM, Ben Christensen
notifications@github.comwrote:

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:


Reply to this email directly or view it on GitHubhttps://github.com//pull/365#issuecomment-24138547
.

@benjchristensen
Copy link
Member Author

The throttleLast is absolutely the same as sample it appears, so I'll remove throttleLast.

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.

5 participants