What is @ngrx/schematics?
@ngrx/schematics is a collection of Angular schematics for generating NgRx files such as actions, reducers, effects, and more. It helps streamline the process of setting up and maintaining NgRx in Angular applications.
What are @ngrx/schematics's main functionalities?
Generate Store
This command generates a new NgRx store with the specified state and sets it up in the root module. It creates necessary files and boilerplate code for the store.
ng generate @ngrx/schematics:store State --root --module app.module.ts
Generate Actions
This command generates a new set of actions for a specified feature (e.g., User). It creates an actions file with predefined action types and classes.
ng generate @ngrx/schematics:action User
Generate Reducer
This command generates a new reducer for a specified feature (e.g., User). It creates a reducer file with initial state, reducer function, and necessary imports.
ng generate @ngrx/schematics:reducer User
Generate Effects
This command generates a new effect for a specified feature (e.g., User). It creates an effects file with boilerplate code for handling side effects in NgRx.
ng generate @ngrx/schematics:effect User
Other packages similar to @ngrx/schematics
@angular/cli
@angular/cli is the official Angular CLI tool that provides a wide range of commands for generating and managing Angular projects. While it does not specifically focus on NgRx, it can be extended with custom schematics to include NgRx-related functionality.
nx
Nx is a set of extensible dev tools for monorepos, which helps you develop like Google, Facebook, and Microsoft. It provides powerful CLI commands for generating and managing Angular applications, including support for NgRx. Nx offers more advanced features for managing large-scale projects compared to @ngrx/schematics.
schematics-utilities
schematics-utilities is a utility library for Angular schematics that provides helper functions for creating and modifying Angular projects. It can be used to create custom schematics, including those for NgRx, but requires more manual setup compared to @ngrx/schematics.
18.0.0-beta.0 (2024-05-20)
Bug Fixes
- eslint-plugin: add as devDependency via ng add (#4343) (4fe7b7f)
- schematics: set correct default value type (#4307) (51034e6)
Features
BREAKING CHANGES
- The minimum required version of Angular has been updated
BEFORE:
The minimum required version of Angular is 17.x
AFTER:
The minimum required version of Angular is 18.x
- store: The Action and TypedAction interfaces are merged into one interface.
BEFORE:
There was a separation between the Action and TypedAction interfaces.
AFTER:
The Action interface accepts a generic type parameter that represents the payload type (defaults to string).
The TypedAction interface is removed.
<a name="17.2.0"></a>