I want to use ngxs for state management in my Angular 6 application.
But I am not sure if it is mature for big projects.
I can not find any articles about Difference in performance between ngrx and ngxs. Can someone provide some info about it?
Performance metrics: Getting a large number of items form the store and writing back into the store.
What is NGXS and how does it work? As I have already mentioned, NGXS is a state management library which is very similar to NGRX, with the difference that it has less boilerplate code and is easier to learn. There are 4 basic concepts in NGXS that you should understand before you integrate it into your project.
When it comes to Angular, NgRx and NGXS are the two most-used libraries for state management, and they have some unique features that make developers' work easy. In this article, I will introduce NgRx and walk you through the steps of creating a simple Angular application using it.
When should you not use NgRx? Never use NgRx if your application is a small one with just a couple of domains or if you want to deliver something quickly. It comes with a lot of boilerplate code, so in some scenarios it will make your coding more difficult.
NgRx, which is the Angular version of Redux for React is for State Management. In React, state management can get complicated, and Redux is there to help. For Angular, this should not be the case as everything is synced due to two way data binding. However, I see a lot of projects using NgRx.
Here is good answer from Reddit (Angular2+ community). It's from a developer who tested both and switched to NGXS.
I would like to share my experience. We have a medium-large enterprise app. We started with NGRX, but it quickly became clear that
NGRX code is much difficult to understand and write to teammates.
NGRX is boilerplate hell. You spend lot of time with it.
The concept of "Effects" is good, but it just adds extra layers of complexity which could be simplified.
Developer Experience (DX) was horrifying.
Then we switched to NGXS.
It has minimum boilerplate. You jump right into "action" :D.
We were delighted by its DX.
It is much easier to understand for teammates and everybody was suddenly productive.
There are some tradeoffs like server calls are in reducers, but it made sense to use after a while.
PLUGINS! There are loads of plugins from logging to forms handling (Awesome thing ever).
From what I'm experiencing, NGXS is way simpler to write and it's easier to work with lazy loaded states. It has such a simple syntax, it's OOP, instead of Redux FP paradigm. Decorate your actions and selectors, subscribe to memoized states, catch dispatched actions anywhere, etc.
However, I found a pitfall when it comes to the storage plugin which is essentially for offline first applications. It uses sync local storage which has a limit of 5MB and will stall the UI when it needs to write big data to storage. However you could write a custom storage solution on top of the plugin. It's scalable, extensible, you can inject the util classes in a breeze, the documentation is as simple as it can be.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With