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

feat(schematics): selector schematics #2160

Merged
merged 5 commits into from Oct 17, 2019
Merged

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?

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

What is the current behavior?

Closes #2140

What is the new behavior?

This PR adds selector schematics with:

ng g selector selectorName
ng g s selectorName
ng g feature featureName

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot
Copy link
Collaborator

ngrxbot commented Oct 10, 2019

Preview docs changes for 0302947 at https://previews.ngrx.io/pr2160-0302947/

@@ -0,0 +1,12 @@
<% if(feature) { %>import { <%= camelize(name) %>FeatureKey } from '<%= reducerPath %>';
Copy link
Member

Choose a reason for hiding this comment

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

This should come out to import * as fromFoo from 'fooReducerPath';

@@ -0,0 +1,6 @@
import { createFeatureSelector, createSelector } from '@ngrx/store';
<% if(feature) { %>import { State, <%= camelize(name) %>FeatureKey } from '<%= reducerPath %>';
Copy link
Member

Choose a reason for hiding this comment

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

Same as above import * as fromFoo ...

@ngrxbot
Copy link
Collaborator

ngrxbot commented Oct 14, 2019

Preview docs changes for 3e89e0f at https://previews.ngrx.io/pr2160-3e89e0f/

return stringUtils.featurePath(
options.group,
options.flat,
'reducers',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'reducers',
'selectors',

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 should stay as reducers, we're building up the path to the reducers file here.
The selector spec file will always live next to the selector file so this import will always be ./selector-featureName.
For reducers we have to navigate to the correct folder because this may vary based on the group and flat flags.

If we would change this, we would import the reducer as:

import * as fromFoo from '../../selectors/foo/foo.reducer'

@@ -57,6 +57,13 @@
"description": "Adds initial setup for state management"
},

"selector": {
"aliases": ["s"],
Copy link
Member

Choose a reason for hiding this comment

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

Let's change the alias to se, the s alias is already being used for services. https://github.com/angular/angular-cli/blob/master/packages/schematics/angular/collection.json#L87

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch, will do 👍

@ngrxbot
Copy link
Collaborator

ngrxbot commented Oct 16, 2019

Preview docs changes for d29f35f at https://previews.ngrx.io/pr2160-d29f35f/

@brandonroberts brandonroberts merged commit 78817c7 into master Oct 17, 2019
@brandonroberts brandonroberts deleted the pr/schematics-selector branch October 17, 2019 03:06
jordanpowell88 pushed a commit to jordanpowell88/platform that referenced this pull request Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Schematics: Generate selectors file as part of feature schematic
3 participants