- Single state tree
- Actions describe updates
- Reducers apply updates
Everything that happens in your app is an action. These can be caused by users, browser events, or server events. Doesn’t matter. Everything that changes something in your app does it via an “action”.
You have one giant state object that represents all the state in your app. These are not special Models, or Collections, it’s just friggin’ objects, arrays, and primitives. No magic.
You write reducers for everything that changes state. Are you familiar with the
.reduce()method of an array? If not, go read this. But a
reducefunction gets a starting state, the current value and returns the new state. That’s exactly what we want to do in response to actions. We get the starting state, the current action, and we return the new state.