ReactJS Flux Concept
Overview of ReactJS Flux Concept :- Flux is the application architecture that Facebook uses for building client-side web applications. It is not a framework or a library. It is simply a new kind of architecture that complements React and the concept of Unidirectional Data Flow, and you can start using Flux immediately without a lot of new code. Flux provides stability to the application and reduces run-time errors.You can see flux architectural pattern in below diagram.
Flux applications have three major parts :
Dispatcher : The Dispatcher is the central hub for your application that manages all data flow in a Flux application. The dispatcher receives actions and dispatches the actions and data to registered callbacks.
Dispatcher is used to broadcast payloads to registered callbacks.
There are pub-sub systems in two ways:
- Callbacks are not subscribed to specific events. All payload is dispatched to every registered callback.
- Callbacks can be deferred in whole or part until other callbacks have been executed.
Stores : Stores contain the application state and logic. it manage the application state for a specific domain within the application.
Views : It is React components that listen to change events and receives the data from the store and re-render the application.