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

fix(min/max): do not return comparer values (#1892) #1923

Merged
merged 2 commits into from
Sep 9, 2016

Conversation

gluck
Copy link
Contributor

@gluck gluck commented Sep 6, 2016

Description:

min (&max) operators have now the expected behavior when used with a comparer:

  • previously they were behaving like reduce and emitting (last) comparer return value
  • they now emit original observable min/max value by comparing the comparer return value to 0

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

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0009%) to 97.128% when pulling d9b7a12 on gluck:min_by_predicate into a61c8b2 on ReactiveX:master.

@kwonoj
Copy link
Member

kwonoj commented Sep 6, 2016

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', () => {
Copy link
Member

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) .

Copy link
Contributor Author

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

@gluck gluck force-pushed the min_by_predicate branch 2 times, most recently from e399334 to b2f447b Compare September 7, 2016 12:08
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0009%) to 97.128% when pulling b2f447b on gluck:min_by_predicate into af4e6a9 on ReactiveX:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0009%) to 97.128% when pulling b2f447b on gluck:min_by_predicate into af4e6a9 on ReactiveX:master.

@gluck
Copy link
Contributor Author

gluck commented Sep 7, 2016

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>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

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
@coveralls
Copy link

Coverage Status

Coverage increased (+0.0009%) to 97.128% when pulling 222fd17 on gluck:min_by_predicate into af4e6a9 on ReactiveX:master.

@kwonoj
Copy link
Member

kwonoj commented Sep 8, 2016

LGTM

@kwonoj kwonoj merged commit 5824f0a into ReactiveX:master Sep 9, 2016
@lock
Copy link

lock bot commented Jun 6, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants