6

We are using ngrx with Angular2 in our current project. Basically ngrx is reactive extension of Redux. ngrx provide single source of truth and the data can be access from everywhere.

We can handle all these scenarios using global services but why to write same code that is already available and tested.

0

3 Answers 3

9

I had the similar question when I came across ngRx. In simple way and as per my understanding:

  1. Using ngRx you basically have a standard mechanism for State Management. We don't have to write extra piece of code that manages states as per the app requirement.

  2. Using ngRx plugins, we can actually time travel and check with what all state changes have the application gone through . That is a big thumbs up as it's not an easy task to implement all by ourselves.

  3. By following standard practices of reducers (pure functions), states (immutable) , selectors & stores basically we are trying to protect our app from any unpredictable changes. We also have effects to handle some scenarios.

  4. It provides a standard practice which can help entire community to stay on the same page. If everyone will write their own global services and achieve most of the things which ngRx provide, it can still be difficult for new comers. So, that's an important point as well.

  5. Refer Flux Architecture

  6. Not every app has to implement ngRx. Sometimes it can make your application messy.So think before you implement.
Sign up to request clarification or add additional context in comments.

Comments

3

In now days subscriber patter is more powerful and robust. You will see the success of redux in React and Angular with ngrx. They have proper mechanism to handle data flow and proper way to manage code. You will not need to write verbose code to manage back and forth data flow using service, they provide all predefined cooked function and peace of code to use.

Use ngrx with effect and Entity Adapter to make things more clear.

But it depends on your application, sometimes it unnecessary add complexity into applications. But if you are not able to manage state on client side then you should go for that.

Comments

2

I have written a library to save you from the hell of ngrx. It is called RxCache.

Take a look at RxCache, it gives you the push based data flow of observable and frees you from the complete insanity of ngrx.

https://github.com/adriandavidbrand/ngx-rxcache

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.