Flux 是一种架构模式(来自 Facebook),用于通过单向(单方向)数据流管理状态。它是 Redux 的概念基础,并影响了大多数现代状态库。核心思想:数据以单一、可预测的方向流动。
单向循环
text
Action → Dispatcher → Store → View
↑ │
└───────────────────────────────────┘
(user interaction creates a new Action)
text
1. Action — a plain object describing WHAT happened ({ type: 'ADD_TODO', text })
2. Dispatcher — a central hub that sends every action to the stores
3. Store — holds state + logic; updates itself in response to actions
4. View — renders from the store; user interactions dispatch new actions
