Skip to content

Commit b5bc4fc

Browse files
author
Peter Smith
committed
feat(feature): ngrx files
1 parent ecd044b commit b5bc4fc

19 files changed

+233
-150
lines changed

libs/ddd/src/schematics/domain/ngrx-files/+state/__fileName__.actions.ts__tmpl__

Lines changed: 0 additions & 20 deletions
This file was deleted.

libs/ddd/src/schematics/domain/ngrx-files/+state/__fileName__.effects.ts__tmpl__

Lines changed: 0 additions & 26 deletions
This file was deleted.

libs/ddd/src/schematics/domain/ngrx-files/+state/__fileName__.facade.ts__tmpl__

Lines changed: 0 additions & 20 deletions
This file was deleted.

libs/ddd/src/schematics/domain/ngrx-files/+state/__fileName__.reducer.ts__tmpl__

Lines changed: 0 additions & 41 deletions
This file was deleted.

libs/ddd/src/schematics/domain/ngrx-files/+state/__fileName__.selectors.ts__tmpl__

Lines changed: 0 additions & 38 deletions
This file was deleted.

libs/ddd/src/schematics/domain/ngrx-files/application/.gitkeep

Whitespace-only changes.

libs/ddd/src/schematics/domain/ngrx-files/entities/.gitkeep

Whitespace-only changes.

libs/ddd/src/schematics/domain/ngrx-files/infrastructure/.gitkeep

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { createAction, props } from '@ngrx/store';
2+
import { <%= classify(entity) %> } from '../../entities/<%= dasherize(entity) %>';
3+
4+
export const load<%= classify(entity) %> = createAction(
5+
'[<%= classify(entity) %>] Load <%= classify(entity) %>'
6+
);
7+
8+
export const load<%= classify(entity) %>Success = createAction(
9+
'[<%= classify(entity) %>] Load <%= classify(entity) %> Success',
10+
props<{ <%= camelize(entity) %>: <%= classify(entity) %>[] }>()
11+
);
12+
13+
export const load<%= classify(entity) %>Failure = createAction(
14+
'[<%= classify(entity) %>] Load <%= classify(entity) %> Failure',
15+
props<{ error: any }>()
16+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Injectable } from '@angular/core';
2+
import { createEffect, Actions, ofType } from '@ngrx/effects';
3+
import { catchError, map, switchMap } from 'rxjs/operators';
4+
import { of } from 'rxjs';
5+
import * as <%= classify(entity) %>Actions from './<%= dasherize(entity) %>.actions';
6+
import { <%= classify(entity) %>DataService } from '../../infrastructure/<%= dasherize(entity) %>.data.service';
7+
8+
@Injectable()
9+
export class <%= classify(entity) %>Effects {
10+
load<%= classify(entity) %>$ = createEffect(() =>
11+
this.actions$.pipe(
12+
ofType(<%= classify(entity) %>Actions.load<%= classify(entity) %>),
13+
switchMap((action) =>
14+
this.<%=camelize(entity)%>DataService.load().pipe(
15+
map((<%= camelize(entity) %>) =>
16+
<%= classify(entity) %>Actions.load<%= classify(entity) %>Success({ <%= camelize(entity) %> })
17+
),
18+
catchError((error) =>
19+
of(<%= classify(entity) %>Actions.load<%= classify(entity) %>Failure({ error }))
20+
)
21+
)
22+
)
23+
)
24+
);
25+
26+
constructor(
27+
private actions$: Actions,
28+
private <%=camelize(entity)%>DataService: <%= classify(entity) %>DataService
29+
) { }
30+
}

0 commit comments

Comments
 (0)