From the course: Learning NgRx
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Core concepts: Reducers and store - Angular Tutorial
From the course: Learning NgRx
Core concepts: Reducers and store
- [Instructor] Welcome to this video where I'm going to talk about reducer and store, two more of the core concepts of Redux and NgRx. We saw earlier that a state gets updated through actions. Reducers are the functions that makes a transition happen. As a result, a reducer is a pure function that takes a current state and an action as a parameter and then returns a brand new state object. It's important to know that a new state is an updated copy of the old one, as getting a new reference helps with change detection in most JavaScript frameworks. Also, reducers only perform synchronous state changes. We'll see later that another kind of feature called effect is used for asynchronous changes. Here is a simple example of reducer. Let's go through it line by line. First, a reducer is a function. Its first parameter is a current state, and if none is passed, we use the initial state of the application as a default. Then we pass the action that we want to perform. Most reducers will have…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.