Why Angular Developers Love NgRx
If you saw any of the recent talks from ngConf, you will probably have seen one on NgRx, it was a huge topic at the conference this year, but why are Angular developers all talking about NgRx?
If you run a team of Angular developers they probably have already mentioned that they are looking to use NgRx in a project sometime soon, why? Well because NgRx solves one large problem, state management. What is state management, well it is a way of managing the state of an application between screens For example if you have a six-step process that needs to add to the application your team is building. In order to pass the information enter in step 1 to step 6, state management gives the developer a way of storing all the information added throughout each step, so it is accessible throughout the entire processes.
Before state management libraries like NgRx, developers use to have different approaches to store the state of the application, from storing all the information in local storage in the browser to cookies and even writing back to a temporary table in a database. With each project, there was probably another way of managing the state of the application.
This means when your developers are working on a project there wasn’t a common approach to the state management problem, but now thankfully due to libraries like NgRx, there is.
Another great feature of libraries like NgRx is the dev tools that come with the library. These ‘dev tools’ are features written into the library that take advantage of the wonderful features of a modern browser, by tapping into the tools the browser gives. Tools that allow the developer to really look into what is happening in the application as it runs. NgRx comes with a feature called store devtools this gives the developers the ability to add or amend the state of the application to see how the app handles different states. This is something that was usually done in the QA stage because it was easier to set up in QA. Now a developer can change the state through their browser to see how the app behaves. The better a developer can test how the app behaves at development time, the fewer bugs, the less time an app spend going through the QA process.
So to recap, Angular developers are loving NgRx at the moment, for two main reasons. One it gives them a standardised way to solve the problem of state management within an application, and two it helps provide fantastic tooling for developers to really look into how the application is working.
But NgRx isn’t the only state management library available, there is also NGXS which is another state management library for Angular. This one takes the approach to be more class-based, thanks to classes in TypeScript, than NgRx, which is more function based. Both tackle the same problem of state management, but NGXS has taken what people have learnt from using NgRx and implemented an approach that uses the great features of TypeScript.
If your team are looking at NgRx it is worth adding to your project, it will help your team with providing a common approach to one of the trickiest parts of building a modern web application.