Redux
- Redux is a library that manages states. Based on functional principals it solves a problem of data flow in an interesting way.
- In an app your data should have a unidirectional flow. The data flows forward, it never comes back.
- A data with changed properties is not same data (Autovalue), it can be a different copy object.
- In redux, you pass an
action
, Areducer
listens to action and changesstore
connects bothacion
andreducer
actoin
: Must have a string, can optionaly have any type of payload.reducer
: Must return a state, it can never throw error or return undefined thing.- In any error case or un-recognized action, it should return previous state passed.
store
: Allows to subscribe/unsubscribe updates, can read current state at any time and sends actions to reducers