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(Store): selector with only a projector #1579

Merged
merged 2 commits into from
Apr 1, 2019

Conversation

timdeschryver
Copy link
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

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

What is the current behavior?

Closes #1558

What is the new behavior?

Does this PR introduce a breaking change?

[x] Yes
[ ] No

BREAKING CHANGE:

Selectors with only a projector function aren't valid anymore.
This change will make the usage more consistent.

BEFORE:

const getTodosById = createSelector(
  (state: TodoAppSchema, id: number) => state.todos.find(p => p.id === id)
);

AFTER:

const getTodosById = createSelector(
  (state: TodoAppSchema) => state.todos,
  (todos: Todo[], id: number) => todos.find(p => p.id === id)
);

@@ -143,17 +143,6 @@ describe('Selectors', () => {
});
});

it('should not short circuit to the projector fn if there are no selectors and props', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was to verify the fix for #1501.
Since we don't short circuit anymore, this test became obsolete.

BREAKING CHANGE:

Selectors with only a projector function aren't valid anymore.
This change will make the usage more consistent.

BEFORE:

```
const getTodosById = createSelector(
  (state: TodoAppSchema, id: number) => state.todos.find(p => p.id === id)
);
```

AFTER:

```
const getTodosById = createSelector(
  (state: TodoAppSchema) => state.todos,
  (todos: Todo[], id: number) => todos.find(p => p.id === id)
);
```
@timdeschryver timdeschryver changed the title fix(Store): remove the possibility to use a selector with only a projector function fix(Store): selector with only a projector Feb 25, 2019
@coveralls
Copy link

coveralls commented Feb 25, 2019

Coverage Status

Coverage decreased (-0.1%) to 89.415% when pulling 3447f87 on pr/selector-projection into 383e6b2 on master.

@ngrxbot
Copy link
Collaborator

ngrxbot commented Feb 25, 2019

Preview docs changes for 3447f87 at https://previews.ngrx.io/pr1579-3447f87/

@brandonroberts
Copy link
Member

Will you put in another PR that deprecates the old method overload?

@ngrxbot
Copy link
Collaborator

ngrxbot commented Apr 1, 2019

Preview docs changes for 26eab59 at https://previews.ngrx.io/pr1579-26eab59/

@brandonroberts brandonroberts merged commit da1ec80 into master Apr 1, 2019
@brandonroberts brandonroberts deleted the pr/selector-projection branch April 1, 2019 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Single createSelector function doesn't get state passed in.
4 participants