-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Conversation
Preview docs changes for 0302947 at https://previews.ngrx.io/pr2160-0302947/ |
@@ -0,0 +1,12 @@ | |||
<% if(feature) { %>import { <%= camelize(name) %>FeatureKey } from '<%= reducerPath %>'; |
There was a problem hiding this comment.
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 %>'; |
There was a problem hiding this comment.
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 ...
Preview docs changes for 3e89e0f at https://previews.ngrx.io/pr2160-3e89e0f/ |
return stringUtils.featurePath( | ||
options.group, | ||
options.flat, | ||
'reducers', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'reducers', | |
'selectors', |
There was a problem hiding this comment.
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'
modules/schematics/collection.json
Outdated
@@ -57,6 +57,13 @@ | |||
"description": "Adds initial setup for state management" | |||
}, | |||
|
|||
"selector": { | |||
"aliases": ["s"], |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will do 👍
Preview docs changes for d29f35f at https://previews.ngrx.io/pr2160-d29f35f/ |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Closes #2140
What is the new behavior?
This PR adds selector schematics with:
Does this PR introduce a breaking change?
Other information