From the course: Building Angular and ASP.NET Core Applications

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

NgRx reducers

NgRx reducers

From the course: Building Angular and ASP.NET Core Applications

Start my 1-month free trial

NgRx reducers

- [Instructor] Now we are going to create a reducer to handle our first action. So let us go to Visual Code, then see that in action. So you will go inside the ClientApp, source, then app, store, and here, we are going to create a new file. We are going to name this file book.reducer.ts, and then, we are going to import all the book actions and the action types. So for that, let's write in here import, all as bookActions from, let's just write book.actions, and then import all as types from dot action.types. Now, for us to be able to use the book actions, we need to export them. So, let us go to the book.actions.ts file and, at the bottom, write export type, so we want to export Actions is equal to loadBookAction pipe loadBooksSuccessAction. Let's save the changes and go back to the reducer file. In here, now, we are going to create a function because we know that reducers are pure functions. So for that, we…

Contents