Contact Us
A 101-103 Siddhivinayak Towers, Off S.G. Highway, Ahmedabad, Gujarat 380051

What is Redux ?? And Reason for using it in angular ?

by Attune World Wide / /

Redux is a library that helps us to manage the state of your application. We have to use Redux for medium to large scale Single page Application with complex data flow. If you are building the small application with simple data flow then you don’t necessarily need Redux and in fact Redux add extra unnecessary complexity in your application.

Introducing Large Single Page Application

Typically Angular Application without the Redux Architecture each component maintain a state and Logic behind the view. However we have problem when we have multiple views and working with the same piece of data and do not have a parent child relationship between the views like below

In this situation we often have multiple copies of the data that are independent to each other (like below) so problem with this approach is that the when we update the model we need to do some extra work to keep the other views in sync.

Since all the views are independent to each other so we need to do some extra work to keep them in sync common solution for that is to use events.

But problem with this approach is that the data is updated in unpredictable way because whenever bug is occur at that time we have to move all over the code to find out how the data is flow in to the Application and how application state is updated at multiple places into the it is unpredictable and adding the new features is challenge.

So facebook faces the same problem so it has introduced the new architecture back in 2014  called flux. And Redux is the simplified and lightweight implementation of this Architecture providing the clean solution for this problem. So Redux is used for maintaining the application state in predictable way.

Following are the Benefits of Redux:

  • Predictable Application State
  • Decoupled Architecture : It decoupled your application from presentation framework like Angular so we can implement big chunks of Application and it’s presentation logic
  • Testability : It will makes the application more unit testable
  • Provide Great Tool : it will provides the some cool tools for development like Redux Developer Tool extension that you can add into the firefox,chrome and other browser. It will allow us to debug your application with inspecting the Application state
  • Undo / Redo : Redux makes Easy to implement the functionality like Undo and Redo.

When to use Redux

  • You have to use the Redux for medium to large application when you have very complex data flow Otherwise Redux adds the extra unnecessary complexity in your application.
  • When you need Independent Copies of the same data in multiple places
  • Multiple views that need to work with the same data and be in sync
  • Data can be updated by multiple users
  • Data can be updated by the multiple Actors

About Attune World Wide

What you can read next

Leave a Reply

Your email address will not be published. Required fields are marked *

fifteen − 14 =

Recent Posts