Search code examples
angularwebstormcode-generationngrxangular-schematics

Code-generation solution for Angular NgRx App


I am currently developing an angular-ngrx app. I am using angular-cli to scaffold the app. My trouble is as my app is growing larger i need to add lot of files eg reducer, action , state, effects files . I want to automate this part, where I could generate these state management files with some boiler plate code. Can I please get some help to begin with it?


Solution

    • You can install @ngrx/schematics in your dependencies, then create new feature's actions/reducers/effects via ng generate

      https://github.com/ngrx/platform/blob/master/docs/schematics/README.md

    • If you're using WebStorm latest version, the IDE can recognize the installed schematics and let you create new actions/reducers/effects

      new via Angular CLI

      Available items

    • Another handy feature of WebStorm is the Live Template, in the below screenshot, I wrote my own NgRx collection:

      Live template