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): Rename default action type for action blueprint #1047

Merged
merged 1 commit into from
May 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Action } from '@ngrx/store';

export enum <%= classify(name) %>ActionTypes {
<%= classify(name) %>Action = '[<%= classify(name) %>] Action'
Load<%= classify(name) %>s = '[<%= classify(name) %>] Load <%= classify(name) %>s'
}

export class <%= classify(name) %> implements Action {
readonly type = <%= classify(name) %>ActionTypes.<%= classify(name) %>Action;
readonly type = <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s;
}

export type <%= classify(name) %>Actions = <%= classify(name) %>;
export type <%= classify(name) %>Actions = Load<%= classify(name) %>s;
Copy link
Contributor

@ThomasBurleson ThomasBurleson May 10, 2018

Choose a reason for hiding this comment

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

@brandonroberts - in the nx schematics, we generate scaffolding for both Load and Loaded and LoadError. And we use union types for the Load/Loaded actions.
e.g.

export type <%= classify(name) %>Actions = 
     Load<%= classify(name) %>s        | 
     <%= classify(name) %>sLoaded      | 
     <%= classify(name) %>sLoadError;

Nx is also missing the s suffix... which I will add/fix.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Actions, Effect } from '@ngrx/effects';
export class <%= classify(name) %>Effects {
<% if(feature) { %>
@Effect()
effect$ = this.actions$.ofType(<%= classify(name) %>ActionTypes.<%= classify(name) %>Action);
effect$ = this.actions$.ofType(<%= classify(name) %>ActionTypes.Load<%= classify(name) %>s);
Copy link
Contributor

@ThomasBurleson ThomasBurleson May 10, 2018

Choose a reason for hiding this comment

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

@brandonroberts - you may want to add this:

loadEffect$ = this.actions$.ofType(<%= classify(name) %>ActionTypes.Load<%= classify(name) %>s);

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 idea.

<% } %>
constructor(private actions$: Actions) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const initialState: State = {
export function reducer(state = initialState, action: <% if(feature) { %><%= classify(name) %>Actions<% } else { %>Action<% } %>): State {
switch (action.type) {
<% if(feature) { %>
case <%= classify(name) %>ActionTypes.<%= classify(name) %>Action:
case <%= classify(name) %>ActionTypes.Load<%= classify(name) %>s:
return state;

<% } %>
Expand Down