-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(min/max): do not return comparer values (#1892) #1923
Conversation
I prefer to split into each commit (personally). In either case, I'd like to suggest to remove issue number from commit message but include in description (https://github.com/ReactiveX/rxjs/blob/master/CONTRIBUTING.md#commit-message-format) |
const e1 = hot('-x-^-a-b-c-d-e-f-g-|'); | ||
const e1subs = '^ !'; | ||
const expected = '----------------(w|)'; | ||
it('should handle a predicate on observable with many values', () => { |
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.
is this test case needed still? originally it was testing predicate returns constant value (which was incorrect assessment), testing execution of predicate is being covered by line 200 (https://github.com/ReactiveX/rxjs/pull/1923/files#diff-1e06648035d9126f1295caf9df494e1cR200) .
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.
fair enough, if the reverse predicate works, it's probably enough
e399334
to
b2f447b
Compare
Done! |
: (x, y) => x < y ? x : y; | ||
return this.lift(new ReduceOperator(min)); | ||
} | ||
|
||
export interface MinSignature<T> { | ||
(comparer?: (x: T, y: T) => T): Observable<T>; | ||
(comparer?: (x: T, y: T) => number): Observable<T>; |
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.
doesn't MaxSignature
(https://github.com/ReactiveX/rxjs/pull/1923/files#diff-31007d130dd79eb825771f50f6eef837R24) need to be updated as well?
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.
Definitely, and done.
max operator have now the expected behavior when used with a comparer: - previously was behaving like _reduce_ and emitting (last) comparer return value - now emits original observable max value by comparing the comparer return value to 0 - fixes ReactiveX#1892
min operator have now the expected behavior when used with a comparer: - previously was behaving like _reduce_ and emitting (last) comparer return value - now emits original observable min value by comparing the comparer return value to 0 - fixes ReactiveX#1892
b2f447b
to
222fd17
Compare
LGTM |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description:
min (&max) operators have now the expected behavior when used with a comparer:
method signatures were changed to have comparer return a number instead of T
unit tests have been updated, the ones relying on a constant comparer have been removed when their outcome should be undefined (more than 1 value in stream and no error/unsub) and replaced by ones with either a basic or reverse comparer.
I can split the PR in 2 commits (one for min and one for max) if you think that'd help on the release notes.
Related issue :
#1892