Skip to content

Latest commit

 

History

History
79 lines (52 loc) · 1.75 KB

reducer.md

File metadata and controls

79 lines (52 loc) · 1.75 KB

Reducer


Overview

Generates a reducer file that contains a state interface, an initial state object for the reducer, and a reducer function.

Command

ng generate reducer ReducerName [options]
OR
ng generate r ReducerName [options]

Options

Nest the reducer file within a folder based on the reducer name.

  • --flat
    • Type: boolean
    • Default: true

Group the reducer file within a reducers folder.

  • --group
    • Alias: -g
    • Type: boolean
    • Default: false

Provide the path to a file containing an Angular Module and the entity reducer will be added to its imports array using StoreModule.forFeature.

  • --module
    • Alias: -m
    • Type: string

Provide the path to a reducers file containing a state interface and an object map of action reducers. The generated reducer interface will be imported and added to the first defined interface within the file. The reducer will be imported and added to the first defined object with an ActionReducerMap type.

  • --reducers
    • Alias: -r
    • Type: string

Generate a spec file alongside the reducer file.

  • --spec
    • Type: boolean
    • Default: true

Examples

Generate a User reducer file add it to a defined map of reducers generated from a feature state.

ng generate reducer User --reducers reducers/index.ts

Generate a User reducer file within a nested folder based on the reducer name.

ng generate reducer User --flat false

Generate a User reducer and register it within the Angular Module in app.module.ts.

ng generate reducer User --module app.module.ts

Generate a User reducer file within a nested reducers folder.

ng generate reducer User --group