-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Operations Aggregate, Average and Sum with selector #657
Operations Aggregate, Average and Sum with selector #657
Conversation
RxJava-pull-requests #590 SUCCESS |
This establishes (or strengthens) a precedent of adding a large number of helper methods for very specific cases to the already massive
|
I'd go for |
* @return an Observable that aggregates the source values with the given accumulator | ||
* function and projects the final result via the resultselector | ||
*/ | ||
public <U, V> Observable<V> aggregate( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is equivalent to:
reduce(seed, accumulator).map(resultSelector)
Why the need for a separate operator and implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know we can combine ops to get one of the new aggregate variant, but I think it might be worth having a direct version which avoids nesting several layers of Observables, Observers and Subscriptions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nesting several layers of Observables, Observers and Subscriptions.
The entire library is based on composition. If we were seeking to avoid that we wouldn't be using a functional style so unless there is a strong performance reason (that isn't a bug with one of the operators themselves) I don't see that as a reason to add a helper operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay.
Issue #653
Remarks:
averageInteger
andsumInteger
(and the other types) are handy if we want to use chained operation invocations (with less overhead):instead of