I am going to make a front end application using Angular(latest version) which is dealing with bundle of microservices.Mainly it is the admin panel of a Payment gateway product. As I have worked with both NGXS state management and also subjects and behavior subjects , want to know which is better to implement in such kind of application which deals with user data. Please let me know ...
-
Have a read of this even though I have deprecated the library it talks about. https://medium.com/@adrianbrand/angular-state-management-with-rxcache-468a865fc3fb then have a look at the demo project for the replacement library I haven't written any docs for yet https://stackblitz.com/edit/angular-ivy-vbpzem?file=src%2Fapp%2Fservices%2Fusers.service.ts It shows how a simple helper library can help you design easy to use RxJs based Angular services. – Adrian Brand Aug 10 '20 at 17:57
-
You could also consider: NgRx, Observable Store, and Subject as a Service using a declarative or procedural approach. Here is an example of a declarative approach to using Subjects: https://www.youtube.com/watch?v=ZdS9uOl4OJk – DeborahK Aug 10 '20 at 23:30
2 Answers
Seeing you have asked a very opinion based question I will give you my opinion. Redux based stores don't have a place in the Angular ecosystem. They solve problems inherent to the React ecosystem that can be solved easily with the Angular dependency injection system. Learn how to structure good Angular services and you will never need to reach for a bloated store library.

- 20,384
- 4
- 39
- 60
You can solve more or less the same problems with both, and I don't think you can go wrong with any of them. So I think it comes down to preference.
From my experience just relying on Subjects and Behaviour Subjects can give you a very elegant solution, but it requires that everybody on the team has a good understanding of RXJS and Subjects. If your team do not have this understanding then NGXS can be a better solution because it gives you more rules to follow.

- 2,740
- 1
- 14
- 17
-
If someone doesn't understand RxJs they are not ready to be working on Angular and will not understand NGXS as it is driven by RxJs. – Adrian Brand Aug 10 '20 at 17:48
-
I agree that you still need a solid understanding of RXJS to do NGXS, but I still think that relying on Subjects and building your state management from scratch with RXJS requires and even deeper understanding of RXJS. Also I think the reality is that RXJS is hard, and not all Angular developers understands it to its full extent. – SnorreDan Aug 10 '20 at 17:55