Methods for registering the State

There are two levels where we can register the State:

  • at the global application level
  • at the feature level.

Registering the State at the global level

The global level means that the entire application can access the state tree made from the Reducers. This is fine for a small application, but if we have a more complex application, we could use the feature level module to register the state tree for that feature.

Example

To register at the global level, we use the StoreModule class from the NgRx Store API to make NgRx aware of the Reducers file we’ve just created. This would look like this:

📝 Note: Press the RUN button to compile and serve the application. Once the app compiles, click on the URL given after Your app can be found at, and see what happens!

When the application compiles, you can open the given link to view your application. Then right-click on the application page, click inspect, move to the console tab, and see how the State is changed with the button click.

Get hands-on with 1400+ tech skills courses.