11. Dispatcher
Central hub that messages all data flow
It is a registry of callbacks into the store
=> mechanism to deliver actions into the stores
Action
Dispatcher
Store
ViewStore
Store
...
12. Actions
triggered by the view
information about changes
Action
Dispatcher
Store
ViewStore
Store
...
13. Store
application state
reacts to specific actions
issue events when data or state updated
Action
Dispatcher
Store
ViewStore
Store
...
15. Race of Flux implementations
relay
flux
alt
reflux
flummox
fluxible
fluxxor
marty.js
16. Problems of Flux
Store contains store change logic and state
The state is being rewritten with every action
Dispatcher cannot dispatch while dispatching
18. Why Redux?
1. One global state
2. New state after each action (Time traveling)
3. State is read-only
4. Changes are made with pure functions (reducers)
5. Hot reload
21. Redux flow - Action
Whenever you want to change the
state of the application, you shoot
off an action.
Action function returns a formatted
action object
22. Redux flow - Reducer
Every reducer:
receive state
return new state
Not mutated old state! new one!
26. Dumb elements
How things look
No app dependencies
Just props for data and callbacks
only UI state
27. Solved issues
1. Delegation is easier
a. top-down props is not required
2. Separation of concerns
a. Data fetching => actions
b. Data decorations => reducer
c. view logic
3. State management
a. App-specific
28. Redux Summary
One store
Reducers === (previousState, action) => newState
State changes only in reducers
Structured code
We have access to state in every moment