Skip to content

Latest commit

 

History

History
88 lines (54 loc) · 2.37 KB

README.md

File metadata and controls

88 lines (54 loc) · 2.37 KB

@ngrx/schematics

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.

Installation

Install @ngrx/schematics from npm:

npm install @ngrx/schematics --save-dev

OR

yarn add @ngrx/schematics --dev

Nightly builds

npm install github:ngrx/schematics-builds --save-dev

OR

yarn add github:ngrx/schematics-builds --dev

Dependencies

After installing @ngrx/schematics, install the NgRx dependencies.

npm install @ngrx/{store,effects,entity,store-devtools} --save

OR

yarn add @ngrx/{store,effects,entity,store-devtools}

Default Schematics Collection

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"
  }
}

Initial State Setup

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

Initial Effects Setup

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

Schematics

API Documentation