From the course: Learning NgRx

What is state management all about? - Angular Tutorial

From the course: Learning NgRx

Start my 1-month free trial

What is state management all about?

- [Narrator] Welcome to this video, where I'm going to talk about state management. We'll see what state management is all about as well as all of the benefit it brings to the table. Today, when we create a new web application, we face a lot of different questions. What to do when server data gets updated, for instance, and how to reflect such updates to all of the connected clients. What happens if the user refreshes the browser URL? Should we reload all of the data, use cached data, or should we restart at the exact same screen, or will the user see something different? Questions also arise regarding sessions. Should they be persistent across tabs or even devices? And how to architect our application. Should components be aware of all of this? Or services? There are many different questions. Answers are not easy and may be different for each project. That's where state management comes into play. What state management does is that it gives us a common architecture, a simple pattern to follow along, with some rules that we can use everywhere, so we can manage the state of our application easily. Using the Redux and state management will help you clarify the inputs and outputs of your application, which, in turn, will allow you to easily control all of the data flows. Now, when we implement state management with Redux, we do what is called reactive programming. It means that our code will be designed to react to state changes, and it will also be designed to respond to user interactions in a common, reactive way that has the additional benefit of being loosely coupled. Angular and RxJS are frameworks that are extremely friendly to reactive programming, which is why Redux, a regular JavaScript library, fits perfectly in that picture. So downside of state management with Redux are that the process is quite verbose and requires a lot of boilerplate code. We'll see that Angular CLI will help us with that, so no worries. Another thing to know about is that the pattern only shines when you use it to do everything. It can takes some time to get into that mindset, but, as you will see, it's really worth the effort. So, let's go for a quick recap before moving on to next video. We saw that state management is all about following patterns and rules that will answer all state-related questions. Reactive programming is the mindset behind all of this, where as a UI, it reacts to updates, but doesn't have to know where such updates come from. Finally, all of these concepts come from Redux, a JavaScript library that is all about state management. Redux is not specific to Angular, but plays very well with it. In our next video, we're going to talk about the first two core concepts of Redux, states and actions.

Contents