Skip to content

Commit

Permalink
feat(Schematics): Rename default action type for action blueprint
Browse files Browse the repository at this point in the history
Closes #1040

BREAKING CHANGE:

The action blueprint has been updated to be less generic, with associated reducer and effects updated for the feature blueprint

BEFORE:

export enum UserActionTypes {
  UserAction = '[User] Action'
}

export class User implements Action {
  readonly type = UserActionTypes.UserAction;
}

export type UserActions = User;

AFTER:

export enum UserActionTypes {
  LoadUsers = '[User] Load Users'
}

export class LoadUsers implements Action {
  readonly type = UserActionTypes.LoadUsers;
}

export type UserActions = LoadUsers;
  • Loading branch information
brandonroberts committed May 10, 2018
1 parent e711c28 commit 244d1de
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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;
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);
<% } %>
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

0 comments on commit 244d1de

Please sign in to comment.