Skip to content

fix(Store): selector with only a projector#1579

Merged
brandonroberts merged 2 commits into
masterfrom
pr/selector-projection
Apr 1, 2019
Merged

fix(Store): selector with only a projector#1579
brandonroberts merged 2 commits into
masterfrom
pr/selector-projection

Conversation

@timdeschryver

Copy link
Copy Markdown
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)
);

});
});

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

Copy link
Copy Markdown
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

coveralls commented Feb 25, 2019

Copy link
Copy Markdown

Coverage Status

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

@ngrxbot

ngrxbot commented Feb 25, 2019

Copy link
Copy Markdown
Collaborator

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

@brandonroberts

Copy link
Copy Markdown
Member

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

@ngrxbot

ngrxbot commented Apr 1, 2019

Copy link
Copy Markdown
Collaborator

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