Skip to content

Commit 94cdb51

Browse files
committed
docs(schematic): adding another entity
1 parent e50e3b0 commit 94cdb51

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

README.md

+33-1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,38 @@ Then run the schematic in any project, assuming the angular/cli is installed and
120120

121121
ng g @briebug/ngrx-entity-schematic:add
122122

123+
## Adding another entity
124+
125+
The schematic does not yet support auto connecting the entity to the root store when running the schematic without the `--init` option. The following steps will be necessary to connect the entity to the store manually.
126+
127+
The following example assumes that an entity named `briebug` was first added with the initialization files (`--init`), followed by another entity named `order` without the initialization files.
128+
129+
1. add to the entity state from the `entity.reducer.ts` to the `state/app.interface.ts`.
130+
131+
```ts
132+
export interface AppState {
133+
router: RouterReducerState<RouterStateUrl>;
134+
briebug: BriebugState;
135+
order: OrderState;
136+
}
137+
```
138+
139+
2. add the entity reducer to the parent/root reducer in `state/app.reducer.ts`.
140+
141+
```ts
142+
export const appReducer: ActionReducerMap<AppState> = {
143+
briebug: briebugReducer,
144+
router: routerReducer,
145+
order: orderReducer
146+
};
147+
```
148+
149+
3. add the effects class to the parent/root Effects module `state/state.module.ts` in the `EffectsModule.forRoot([])` array.
150+
151+
```ts
152+
EffectsModule.forRoot([BriebugEffects, OrderEffects]),
153+
```
154+
123155
## Local Development
124156

125157
### Link the schematic to the `sandbox-app`
@@ -150,7 +182,7 @@ run the launch command with any inline options
150182

151183
### Test commands
152184

153-
The test command expects and entity name of `briebug` to test how the schematic runs inside the sandbox-app. Changing this script should require changes to the sandbox-app and understanding of the consequences.
185+
The test command expects an entity name of `briebug` to test how the schematic runs inside the sandbox-app. Changing this script should require changes to the sandbox-app and understanding of the consequences.
154186

155187
"test:ci": "yarn clean:build:launch briebug --init && yarn test:sandbox && yarn clean"
156188

0 commit comments

Comments
 (0)