Módulo 3 de 18 · Diagrama de flujo
Redux Abstracted
Redux abstracted example
Let's see an example and try to understand how redux works under the hood.
Imagine there is a 4-member family. And they have a common balance (a cashier were they store money). The balance holds the money.
There are two types of actions that can be made, either a deposit to the balance, so to put some money there, or a withdraw, to get some money out of the balance.
The family has trusted the father to listen to these two actions and actually perform them. Attention: The father's only job is to manage these actions, he is not capable to decide that a deposit should be made though! Only the mother, the son and the daughter can decide that either a deposit or a withdraw should be made.
Then they just inform the father, that he must execute unquestioningly the corresponding action. He is like the bank manager, and the other three are the clients.
At the end though he is the person who puts the money, or takes the money off the balance.
Once the balance is updated, all the people who have subscribed to it (that means who have access to it) like the mother, the son and the daughter they can see the updated balance (or the updated state if you prefer).
Now how is this related to Redux? Let's see a slide further.