Scaffolding library for Angular applications using NgRx libraries.
@ngrx/schematics provides CLI commands for generating files when building new NgRx feature areas and expanding existing ones. Built on top of Schematics
, this tool integrates with the Angular CLI
.
Install @ngrx/schematics from npm:
npm install @ngrx/schematics --save-dev
yarn add @ngrx/schematics --dev
npm install github:ngrx/schematics-builds --save-dev
yarn add github:ngrx/schematics-builds --dev
After installing @ngrx/schematics
, install the NgRx dependencies.
npm install @ngrx/{store,effects,entity,store-devtools} --save
yarn add @ngrx/{store,effects,entity,store-devtools}
To use @ngrx/schematics
as the default collection in your Angular CLI project,
add it to your angular.json
:
ng config cli.defaultCollection @ngrx/schematics
The collection schema also has aliases to the most common schematics used to generate files.
The @ngrx/schematics
extend the default @schematics/angular
collection. If you want to set defaults for schematics such as generating components with scss file, you must change the schematics package name from @schematics/angular
to @ngrx/schematics
in angular.json
:
"schematics": {
"@ngrx/schematics:component": {
"styleext": "scss"
}
}
Generate the initial state management and register it within the app.module.ts
ng generate @ngrx/schematics:store State --root --module app.module.ts
Note that
@ngrx/schematics:store
is only needed when the default collection isn't set to@ngrx/schematics
Generate the root effects and register it within the app.module.ts
ng generate @ngrx/schematics:effect App --root --module app.module.ts
Note that
@ngrx/schematics:effect
is only needed when the default collection isn't set to@ngrx/schematics