In the last section we finish up a rather long analogy I apologize for it being so long but we're now
going to take all this idea behind this insurance company and we're going to apply it to the world of
redux.
And you're going to very quickly see that every step that we went through with this insurance company
analogy mounts up perfectly to the redux world.
So let's get to it.
All right so here is our original diagram with the redux cycle.
We didn't really talk about the redux cycle at all.
But now without really talking about it you really have an understanding of what each of these things
are and what the purpose of each one is on the bottom here.
I've taken a different step of the flow inside of our insurance company and we've mapped it up to a
different step inside the redux cycle.
So let's start first with the two boxes on the left hand side for each read cycle an insurance company.
So we had said that everything inside of our insurance company started off with some one some customer
dropping a form off that form contains some amount of information that described how they wanted to
change some data within our company.
The form itself had a type and a payload.
So those two steps right there a customer chopping off a form and the form itself is identical to an
action Creator in redux and in action and action creator is a function that is going to create or return
a plain javascript object we refer to this plain javascript object as an action an action has a type
property and a payload property that type property on in-action describes some change that we want to
make inside of our data.
And then the pallete property describes some contexts around the change that we want to make the form
that we discussed and the action are absolutely equivalent in nature.
Remember we had said that for our insurance company we would take that form make copies of it and then
pass it off to each different department and then it would be up to our department to look at the details
on that form and decide how to change the data that that company or that department was maintaining.
So the same thing is true of the action inside of the world of redux.
The purpose of an action is to describe some change that we want to make to the data inside of our application.
And in both cases the person dropping off the form and this action create over here the only purpose
that they serve is to create the form or the action.
Now after this customer dropped off the form it was given to the form receiver and the former receiver
made copies of that form and handed it off to each department.
That is the same purpose of what we call the dispatch function in the world of redux.
So the dispatch function is going to take in action.
It's going to make copies of that object and then pass it off to a bunch of different places inside
of our application.
And that leads us to the reducer over here.
So remember we had said that each department essentially has its own little separate piece of data like
a list of policies or a list of all the claims or the current accounting total like how much money we
have in the bank so to speak.
So each department has its own separate little separate Siskiyou is its own separate little slice of
data inside an application.
The same is true of our producers inside of redux in redux a reducer is a function that is responsible
for taking in an action and some existing amount of data its going to process that action and then make
some change to the data and then return it so that it can then be centralized in some other location.
So the exact same thing that a department is doing.
Remember that department took in a form it looked at the type of the form and it decided how to update
its data reducers going to do the same thing its going to take an action look at the action look at
its type and then based on that type decide how to update its data when a department returns some data
or is done processing a form and then spat out some list of data or some list of current policies or
whatever it might be on the other side and all that information was then assembled into some common
repository of data.
Remember that was this thing appeared this was our central repository of data that the management could
very easily look into and get access to all of our claims history all of our policies and all of our
accounting as well.
And so that is the exact same purpose as the state property inside of redux and redux the state property
is a central repository of all information that has been created by our reducers or by our department
so to speak.
All the information gets consolidated inside the state object so that are re-act application can very
easily reach in to our redux application the redux side of the app and get access to all of the data
of our application.
And in that way our re-act up doesn't have to go around to each separate reducer or member each separate
department and knock on the door and ask for the current list of policies or the current state so to
speak.
OK.
So that is how our insurance company example maps up one to one with every step along the way here.
Now when I just take these different concepts are these different steps of our insurance company analogy
and try to assign them to these different pieces of the cycle.
It still doesn't really give you a lot of context about what the ideas here are and how we actually
write some code to make this happen.
So let's take a quick pause here.
When we come back the next section we're going to start to move over de-code pen and we're going to
write out some code to model our entire insurance company and every step along the way and along that
process you're going to see these action crater's these actions dispatch producers and state and you'll
understand the purpose of each one of those along the flow.
So quick pause here and we'll continue in the next video.