How ruanyf/extremely-simple-flux-demo works
Major components and their responsibilities
• Views:
• Components under the “components” folder: MyButtonController.jsx (controller view) and MyButton.jsx (pure, stateless view). These components render the UI and interact with the user.
• That index.jsx ties everything together by rendering the controller component.
• Actions:
• The “actions” folder contains ButtonActions.js which defines the action creator that dispatches actions (such as ADD_NEW_ITEM) when the user interacts with the UI.
• Dispatcher:
• Located in the “dispatcher” folder, AppDispatcher.js encapsulates the central flux dispatcher using Facebook’s flux.Dispatcher. It accepts actions and propagates them to the stores.
• Stores:
• The “stores” folder includes ListStore.js that manages application state, handles the action payload (e.g., by adding a new item), and emits change events for the views to update.
Architectural patterns and design principles
• Unidirectional Data Flow:
• “one way” data flow: Views → Actions → Dispatcher → Stores → Views.
• Separation of concerns:
• Clearly delineate the responsibilities of UI (Views), event generation (Actions), central event propagation (Dispatcher), and state management (Stores).
Relevant technologies and frameworks
• React (for building the UI in the components folder).
• Mention the usage of Flux (as implemented by the Dispatcher and associated libraries).
• Optionally point out additional libraries: EventEmitter (used within ListStore) and object-assign (for extending objects).