What is the Flux?
As time going our application becomes bigger and complex that means there is an increase in data. For data management, we want a better handling approach for it. So, Facebook released called Flux for dealing with data.
A flux is not a framework and library. It is an architecture uses initially for creating a client-side application with React. Simply, React is a programming concept in that data flow in uni-directional i.e. at the top data entry in the unidirectional flow until it executes on the screen. It is very helpful if the project application is in dynamic form due to that there is reduce in a runtime error.
Flux has four component that is the bases of architecture:
- Controller Views
Elements OF Flux
- Actions: It is used to trigger a dispatcher for data flow including a payload of data. It has two methods i.e. action creator or helper for data flow in the architecture.
- Dispatcher: It is the main hub of the application which used for managing all data flow. It has no intelligence to decide according to it, it simply disturbs actions to the stores, and after that stores provide a callback. It also handles all events in the store. It has five methods for API such as register(), unregister(), waitFor(), dispatch(), and isDispatching().
- Store: It is similar to the MVC model as it contains application logic and state. It is also used for maintaining event for the application.
- Views: It is used to receive data from the store and re-render the app.
Advantage of Flux
- It follows a uni-directional data flow that helps us to understand easily.
- It easy to maintain the application.
- It is an open-source.