-
-
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): add support for reducer creators
Closes #1764, 1766
- Loading branch information
1 parent
be106c9
commit 42097f0
Showing
29 changed files
with
242 additions
and
164 deletions.
There are no files selected for viewing
11 changes: 1 addition & 10 deletions
11
...rc/action/creator-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,14 +1,5 @@ | ||
import { createAction, union } from '@ngrx/store'; | ||
import { createAction } from '@ngrx/store'; | ||
|
||
export const load<%= classify(name) %>s = createAction('[<%= classify(name) %>] Load <%= classify(name) %>s'); | ||
<% if (api) { %>export const load<%= classify(name) %>sSuccess = createAction('[<%= classify(name) %>] Load <%= classify(name) %>s Success');<% } %> | ||
<% if (api) { %>export const load<%= classify(name) %>sFailure = createAction('[<%= classify(name) %>] Load <%= classify(name) %>s Failure');<% } %> | ||
|
||
const all = union({ | ||
load<%= classify(name) %>s, | ||
<% if (api) { %> | ||
load<%= classify(name) %>sSuccess, | ||
load<%= classify(name) %>sFailure | ||
<% } %> | ||
}); | ||
export Union = typeof all; |
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
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
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
74 changes: 49 additions & 25 deletions
74
...tor-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,29 +1,53 @@ | ||
import { createAction, props, union } from '@ngrx/store'; | ||
import { createAction, 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) %>: <%= 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<{ id: string[] }>()); | ||
export const clear<%= classify(name) %>s = createAction('[<%= classify(name) %>/API] Clear <%= classify(name) %>s'); | ||
|
||
const all = union({ | ||
load<%= classify(name) %>s, | ||
add<%= classify(name) %>, | ||
upsert<%= classify(name) %>, | ||
add<%= classify(name) %>s, | ||
upsert<%= classify(name) %>s, | ||
update<%= classify(name) %>, | ||
update<%= classify(name) %>s, | ||
delete<%= classify(name) %>, | ||
delete<%= classify(name) %>s, | ||
clear<%= classify(name) %>s | ||
}); | ||
export type Union = typeof all; | ||
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) %>: <%= 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<{ id: string[] }>() | ||
); | ||
|
||
export const clear<%= classify(name) %>s = createAction( | ||
'[<%= classify(name) %>/API] Clear <%= classify(name) %>s' | ||
); |
Oops, something went wrong.