This article has nothing to with Mafia whatsoever. I have used Mafia story to explain the REDUX in easy terms.
Now its a Storytime
As we all know there is always one Mafia in every city and he with the help of his butlers makes the life of fellow citizen a bit harder and then there is the Police which makes your life easy by beating these criminals.
In our case, Consider React as Mafia which just makes a little hard to share state between deeply nested Components and REDUX as Police who makes easy to share state between components.
One day Mafia asks Buttler to bring 20 beers from his nearby shop. Buttler goes to beer shop and brings 10 beers ( as he drank 10 beer bottles on the road itself). When Mafia asks where the hell are 10 bottles, he tells that shopkeeper denied to give 20 bottles and gave 10 instead.
But Mafia somehow figures out that his Buttler is lying and orders his friend to find a solution. His friends suggest him to develop a Web App so that he can monitor the stocks directly from home itself.
Now, What is the relationship between Mafia and REDUX? It is just to make things easy.
Moral of the Story is
The Mafia is React — — Asking for a beer is actionType — — Buttler is action maker(who goes to store) — — Store is Beer shop — — Shopkeeper is a reducer — — — Police is like Redux which makes It way to share state.
Still not clear, Let's go through Flow Chart and Github repo itself.
The action-type shows the intent i.e, type of action which we want to perform like Get or Set. The action creator is like a function which must return type and payload if any as a response(Consider action creator as a function and make calls through it only.). The reducers job is to do an actual task that is executing the action. Reducer is the only way to interact with the store.
Now go through the Git repository shared and try to relate the things with our Mafia story.