In the last video we started talking about the redux library and this video we're now going to start
to discuss exactly how we're going to cover this library.
So a couple of different steps right here in this video in the next couple.
I can tell you a little story or a quick analogy to help you understand how redux works internally.
After that we're going to write a little bit of code pin or code into Code been with redux by itself.
So no re-act involved whatsoever in these first two steps right here.
That we're going to go through it in the next couple of videos.
You're going to get a good idea of what redux does by itself in isolation without re-act involved at
all.
After we understand how redux works by itself then we'll start to work on a re-act up and understand
how to mix react in redux together in some appropriate fashion.
All right.
So in this video we're going to start off with an analogy and this analogy is going to be a little complicated
but it's really going to help you understand exactly how redux works internally by giving you some real
world concepts to relate all this stuff to.
All right so first thing I want to tell you about is the redux cycle.
You might have seen a diagram that looks like this right here or even some of these pieces of terminology.
If you've ever looked at the redux documentation or read a blog post or another tutorial about redux.
These are a bunch of very fancy turns you see inside of here that describe what happens internally inside
of redux.
If I just give you a description of what happens during each of these steps it can be kind of hard to
really understand the purpose of each step.
And so that's why I'm going to give you an analogy this analogy is going to help you understand exactly
what an actual creator is what an action is what the dispatches reducers instate and so on.
It's going to help you understand every step along the way.
So as we go through this little story it's going to seem a little bit complex at times but remember
I'm telling you this story to give you a real world grounding on the purpose of each of these steps.
So let me tell you my story.
We are going to imagine that you and I are going to build an insurance company.
Now if you're not familiar with a insurance company and its purpose essentially a insurance company
offers people common people like just like you and me to pay some monthly amount of money and then if
something bad happens to you or me like we crash a car or we break a bone or we die you know whatever
bad thing might happen the insurance company will pay out some lump sum or essentially just some amount
of money.
Now an insurance company has two important terms you need to understand to make this story makes sense.
These two terms right here are insurance related terms.
They are not redux ones so don't worry about memorize them.
Memorize them for the purpose of the redux library.
First off we have a policy.
A customer like you or me will purchase or hold a policy.
A policy is essentially a contract between a customer and an insurance company that says if something
bad happens to the customer the insurance company will pay out some amount of money.
Now the other important term here to understand an insurance company is a claim a claim is something
that a customer files or reports to an insurance company.
They do so to essentially get some money from the insurance company.
So if I have a policy with a company and I get into an accident I will file a claim with the company
to say hey I was just in an accident.
I think this should be covered by my policy and I think you should pay me some amount of money.
All right.
Now that we understand this.
Let's go through a quick scenario here.
So this is a diagram of our insurance company that we are trying to build.
This is our headquarters right here.
Our headquarters has a couple of different departments inside of it.
We have a claims history department.
We have a policies department and end and counting department as well.
And I'll tell you about the purpose of each of those in just a second.
I want to walk through what might happen if some new customer comes to our company to sign up for a
new policy.
Remember a policy is a contract that's going to cover this customer so we're going to start off over
here.
We're going to walk through this entire diagram from left to right.
We have a customer right here.
They want to get a new policy.
So they are going to fill out some form that essentially says I want to get a policy so that if I get
into a car crash I can get some paid some amount of money to cover expenses in order to sign up for
a policy.
They are going to fill out a form and then they will come to our insurance company headquarters.
Now the customer is not just going to go up to one of these departments and hand the form off.
Instead we're going to say that our customer has to take this form and hand it off to some front office
or front counter right here that we will refer to as the form receiver.
This former CVS right here is a person who is going to take that form and then make a copy of it with
say a photocopier or a copy machine.
They'll make some copies of the form and then they're going to hand off copies of the form to each of
the different departments that exist inside of our company.
So the claims history department gets one copy the form the policies department gets another copy in
the accounting department gets another copy.
Now remember this form right here.
The purpose of it was to sign up for a new policy.
So chances are that the claims history department who's probably going to maintain a list of claims
it probably doesn't care about this form.
Nonetheless they will be given a copy of it anyways.
Now let's talk about the purpose of each of these different departments that claims history department
is going to store a list of every claim that has been ever made out this company.
And I remember a claim is essentially a request to get some amount of money and each time that a customer
has something bad happened to them.
Next up is the policies Department.
This department is in charge of storing a list of everyone who has a policy an active policy with our
insurance company.
And then finally the accounting department is going to store a big bag of cash.
And any time that someone follows file has me anytime someone files a claim and tries to get some money.
Our accounting department is going to be responsible for paying some money out to that person.
So if we think about a customer over here trying to sign up for a new policy this form right here probably
says something like Hey I want to sign up for a policy.
And chances are that the only department here that really cares about that will be the policies department.
Like I said the claims history department probably doesn't care that you want to sign up for a new policy.
They just record a list of claims.
All right.
So that's kind of step one of this little story here.
All right so let's kind of lay some foundation.
It tells you how a customer interacts with our insurance company member.
They take that form and hand it off to the former Stever the former receiver makes copies of the form
and hands it off to each different department.
And we know what each different department now does.
So there's a couple of more steps to this story.
So let's take a pause right here.
When we come back in the next section I'm going to lay out another little scenario here related to our
insurance company.
And then remember we're going to eventually relate it back to these different pieces of terminology
over here.
So quick pause and I'll see you in just a minute.