-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schematics): Use createActionGroup in schematics (#3791)
- Loading branch information
Showing
10 changed files
with
59 additions
and
90 deletions.
There are no files selected for viewing
23 changes: 9 additions & 14 deletions
23
...matics/src/action/files/__name@dasherize@if-flat__/__name@dasherize__.actions.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, emptyProps, props } from '@ngrx/store'; | ||
|
||
export const <%= prefix %><%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s' | ||
); | ||
|
||
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sSuccess = createAction( | ||
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Success', | ||
props<{ data: unknown }>() | ||
);<% } %> | ||
|
||
<% if (api) { %>export const <%= prefix %><%= classify(name) %>sFailure = createAction( | ||
'[<%= classify(name) %>] <%= classify(prefix) %> <%= classify(name) %>s Failure', | ||
props<{ error: unknown }>() | ||
);<% } %> | ||
export const <%= classify(name) %>Actions = createActionGroup({ | ||
source: '<%= classify(name) %>', | ||
events: { | ||
'<%= classify(prefix) %> <%= classify(name) %>s': emptyProps(), | ||
<% if (api) { %>'<%= classify(prefix) %> <%= classify(name) %>s Success': props<{ data: unknown }>(),<% } %> | ||
<% if (api) { %>'<%= classify(prefix) %> <%= classify(name) %>s Failure': props<{ error: unknown }>(),<% } %> | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 16 additions & 49 deletions
65
...ity/files/__name@dasherize@if-flat__/__name@dasherize@group-actions__.actions.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,20 @@ | ||
import { createAction, props } from '@ngrx/store'; | ||
import { createActionGroup, emptyProps, props } from '@ngrx/store'; | ||
import { Update } from '@ngrx/entity'; | ||
|
||
import { <%= classify(name) %> } from '<%= featurePath(group, flat, "models", dasherize(name)) %><%= dasherize(name) %>.model'; | ||
|
||
export const load<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Load <%= classify(name) %>s', | ||
props<{ <%= camelize(name) %>s: <%= classify(name) %>[] }>() | ||
); | ||
|
||
export const add<%= classify(name) %> = createAction( | ||
'[<%= classify(name) %>/API] Add <%= classify(name) %>', | ||
props<{ <%= camelize(name) %>: <%= classify(name) %> }>() | ||
); | ||
|
||
export const upsert<%= classify(name) %> = createAction( | ||
'[<%= classify(name) %>/API] Upsert <%= classify(name) %>', | ||
props<{ <%= camelize(name) %>: <%= classify(name) %> }>() | ||
); | ||
|
||
export const add<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Add <%= classify(name) %>s', | ||
props<{ <%= camelize(name) %>s: <%= classify(name) %>[] }>() | ||
); | ||
|
||
export const upsert<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Upsert <%= classify(name) %>s', | ||
props<{ <%= camelize(name) %>s: <%= classify(name) %>[] }>() | ||
); | ||
|
||
export const update<%= classify(name) %> = createAction( | ||
'[<%= classify(name) %>/API] Update <%= classify(name) %>', | ||
props<{ <%= camelize(name) %>: Update<<%= classify(name) %>> }>() | ||
); | ||
|
||
export const update<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Update <%= classify(name) %>s', | ||
props<{ <%= camelize(name) %>s: Update<<%= classify(name) %>>[] }>() | ||
); | ||
|
||
export const delete<%= classify(name) %> = createAction( | ||
'[<%= classify(name) %>/API] Delete <%= classify(name) %>', | ||
props<{ id: string }>() | ||
); | ||
|
||
export const delete<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Delete <%= classify(name) %>s', | ||
props<{ ids: string[] }>() | ||
); | ||
|
||
export const clear<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Clear <%= classify(name) %>s' | ||
); | ||
export const <%= classify(name) %>Actions = createActionGroup({ | ||
source: '<%= classify(name) %>/API', | ||
events: { | ||
'Load <%= classify(name) %>s': props<{ <%= camelize(name) %>s: <%= classify(name) %>[] }>(), | ||
'Add <%= classify(name) %>': props<{ <%= camelize(name) %>: <%= classify(name) %> }>(), | ||
'Upsert <%= classify(name) %>': props<{ <%= camelize(name) %>: <%= classify(name) %> }>(), | ||
'Add <%= classify(name) %>s': props<{ <%= camelize(name) %>: <%= classify(name) %>[] }>(), | ||
'Upsert <%= classify(name) %>s': props<{ <%= camelize(name) %>: <%= classify(name) %>[] }>(), | ||
'Update <%= classify(name) %>': props<{ <%= camelize(name) %>: Update<<%= classify(name) %>> }>(), | ||
'Update <%= classify(name) %>s': props<{ <%= camelize(name) %>s: Update<<%= classify(name) %>>[] }>(), | ||
'Delete <%= classify(name) %>': props<{ id: string }>(), | ||
'Delete <%= classify(name) %>s': props<{ ids: string[] }>(), | ||
'Clear <%= classify(name) %>s': emptyProps(), | ||
} | ||
}); |
2 changes: 1 addition & 1 deletion
2
...ty/files/__name@dasherize@if-flat__/__name@dasherize@group-reducers__.reducer.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...atics/src/reducer/files/__name@dasherize@if-flat__/__name@dasherize__.reducer.ts.template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters