‫So as I just said,
‫now it's time to build our action creator functions.
‫So basically, action creators are nothing more
‫than simply functions, that return actions.
‫So they are really not a Redux thing,
‫and Redux would work perfectly fine without them,
‫but they are a useful convention
‫that Redux developers have used forever, basically.
‫So Redux would work without action creators
‫but since it's a convention, let's now create some.
‫So basically we are going to create one action creator
‫for each possible action.
‫So let's call one "deposit".
‫Let's duplicate this.
‫One is "withdraw".
‫One is "request loan"
‫and the other one is "payLoan".
‫All right.
‫So again, these functions all they do
‫is to return actions.
‫And an action is basically just this object.
‫So let's copy this one,
‫then return it.
‫But of course we now need to customize this value here.
‫And so this is gonna be the input of this function.
‫So let's call this the "amount",
‫and then here we replace that with the "amount".
‫So let's comment out all of this right here,
‫so that we can basically recreate the same thing
‫but with our new action creators.
‫So the way it works now
‫is that we still of course call "store.dispatch," like this.
‫But in here,
‫instead of writing the event
‫we just call the "deposit" function with our amount.
‫And then "store.getST" is what we want to log
‫to the console.
‫And yeah, we have the exact same result as before.
‫Okay, and so let's now copy this here.
‫And here it is now "withdraw"
‫and it also needs an amount.
‫Try this one as well.
‫Maybe 200 again,
‫and nice.
‫So I think that this actually looks a lot nicer,
‫and it is especially a lot more reusable
‫than always writing the object here by hand.
‫So that might create a problem
‫that we write something wrong here, so maybe a typo,
‫or maybe we don't remember the right string.
‫And so then that can introduce bugs.
‫All right , right now of course you could create
‫the same convention, so this exact same pattern
‫also with use reducer.
‫So that would be pretty easy to do, right?
‫So here again, let's copy what we had before.
‫And then here we need to specify the "amount"
‫and the "purpose" when we call this action creator.
‫So here we can simply erase this.
‫And so, let's do that.
‫So "requestLoan."
‫And again, we're going to request 1000 to "Buy a cheap car."
‫And then let's log it again to the console. Nice.
‫And now just one more.
‫So "return".
‫And this one of course doesn't even need any input,
‫because here all we need to do is to create this object
‫with the type of "account payLoan".
‫So "store.dispatch," and then "payLoan."
‫And let's see, and nothing happened.
‫So we get exactly the same state as before.
‫And I see, so here we have a typo.
‫So this is exactly the kind of typo
‫that I mentioned earlier.
‫That can always happen.
‫And so now it is correct.
‫Okay. And that's all there is to know
‫about building action creator functions.
‫Now, back in the day, React developers
‫also used to place these strings here
‫into separate variables into a separate file.
‫So for example, we could have one variable
‫called "ACCOUNT DEPOSIT,"
‫which would then contain this string right here.
‫And then we place that right there.
‫And also here.
‫And so then we would also have
‫the action name string here in one central place
‫without having to manually write it twice.
‫So that is also something that you will see
‫in older code bases.
‫And so that's why it's important
‫that you are aware that this exists.
‫However, in more modern React, that is no longer being used.
‫And so we will just go back to the way that we had earlier.
‫But again, if you work with an older code base
‫and you see something like this,
‫then you already know what that means.
‫Okay.
‫And with this, we finish this part
‫and next we will add some more state here.