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

docs: square odds example in rxjs guide #24947

Closed
wants to merge 1 commit into from

Conversation

palerdot
Copy link
Contributor

@palerdot palerdot commented Jul 18, 2018

The example squareOdd for showing squaring odd numbers using RxJS operators is wrong. The current snippet will square even numbers. The same example is shown correctly in the chaining section.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[x] Documentation content changes
[] angular.io application / infrastructure changes
[ ] Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@JanMalch
Copy link

JanMalch commented Jul 18, 2018

Did you test it? It works correctly, because n % 2 for even numbers is 0, which evaluates to false for booleans.
If there is a problem, then it's that TypeScript has a problem with the result being number and not boolean. Your solution is better in that case and better to read, but in JavaScript the code is working as intended.

@brandonroberts brandonroberts self-assigned this Jul 18, 2018
Copy link
Contributor

@brandonroberts brandonroberts left a comment

Choose a reason for hiding this comment

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

The git commit message should be updated to docs: square odds example in rxjs guide

@@ -8,7 +8,7 @@ const nums = of(1, 2, 3, 4, 5);

// Create a function that accepts an Observable.
const squareOddVals = pipe(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be updated to add a type to the n value in the filter function. See #24560 for context.

@brandonroberts brandonroberts added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews comp: docs target: patch This PR is targeted for the next patch release labels Jul 18, 2018
@palerdot palerdot changed the title docs(aio): Fix wrong RxJS code snippet docs: square odds example in rxjs guide Jul 19, 2018
@brandonroberts
Copy link
Contributor

@palerdot squash these down to a single commit with the updated message.

Added argument type to filter function of rxjs. Fixed the
return value of filtering of odd numbers
@palerdot
Copy link
Contributor Author

@brandonroberts squashed into a single commit

@brandonroberts brandonroberts added docsarea: observables and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jul 23, 2018
@brandonroberts brandonroberts added the action: merge The PR is ready for merge by the caretaker label Jul 23, 2018
vicb pushed a commit that referenced this pull request Jul 23, 2018
Added argument type to filter function of rxjs. Fixed the
return value of filtering of odd numbers

PR Close #24947
@vicb vicb closed this in 7c89af3 Jul 23, 2018
@jenniferfell jenniferfell added the state: community Someone from the Angular community is working on this issue or submitted this PR label Oct 9, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes state: community Someone from the Angular community is working on this issue or submitted this PR target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants