While working with actions, a better way we can set them up is by saving them in variable and then
using the variable instead and why we would want to do that one.
All this, of course, we are dispatching our actions, but since they're strong, it's very easy to
make a typo.
For example, if I'm going to copy and paste two more times and if everything is correct, of course
my value should be for.
But what if I make a typo, for example, or make a typo?
Now, of course, the action does not match and my value instead of four is to see what happens.
I dispatch this action two times.
However, in my producer, none of the statements match to whatever action I dispatched and it's very
hard to find it because we also don't get the error correct.
If we just have a string, we had a typo and then we can spend all day looking for the bug, even though
it's just as simple as missing one letter.
And that's why a better setup is setting up actions as variables.
How that would look like, again, common practice is using the uppercase.
So, for example, we have what for actions?
Correct.
So in my case, I'm going to go with the crease, let me go with uppercase in this case.
So I'm going to decrease and that will be equal to my string value of decrease as well.
So let me just read time that I have my decrease.
And now instead of using the string everywhere where I set up that action type, instead I'm going to
use my decrease variable.
So decrease in reducer and the same goes for my dispatch instead of string.
I'm just going to keep it as a variable.
And in this case, if I have a typo right away, I'm going to have a big fat error.
For example, notice we have the error where it says, you know what, you haven't defined this variable.
And of course, I haven't defined it because the name is decrease, not the one that I have here.
So that's why it is much more better setup if we have our actions as a variables.
And in those variables, we hold the value for our string.
And then since usually you have more than just one action, a common practice is setting up a separate
file altogether.
So where I have the source, I'm going to create a new file.
And you guessed it, I'm going to call this actions SJS.
Now, in the actions Jass, I would want to set up my variables.
Of course I would want to export them.
So in Apgar's and then later in the reducers file, I can import them.
So one by one we're going to go with export.
And of course it's going to be named import, not a default one, since there's going to be multiple
actions and now we're just going to name them.
And I'm right away going to write my actions for the application we're going to build.
So not for just testing out the redox, but in fact all the actions we're going to use later on.
That's why some of them we're not going to be using, of course, in reducer.
But I would want to set them up right away.
So I'm going to go decrease.
Decrease and that is going to be equal to my decreased strength.
Then let me copy and paste five times because I would want to have six values.
I'm going to use Command D to delete all of them like so.
And then one by one, let's set them up.
So I'm going to use two cursors.
In this case, I'm going to go with increase.
The next one is remove.
So that is responsible for removing a single item that is going to be a fraction.
After that, we're going to have action to clear the whole card.
So clear cut after that we're going to have Gaturro and get the amount.
So get total.
Now, I do need to place here the underscore in between and then also I'm going to have the same thing
for Garamond.
Reselected get.
And we can say it a lot works well, and now, of course, if we are exporting, we also need to import
in our armchairs for the time being.
We're not going to import all of them because, again, we're just testing out.
So I would just want to import decrease and increase.
And in fact, I will remove the other to the reset and change name since again, this is just for practicing
redox.
It's not going to be implemented in our application.
So let me delete, of course, my two statements.
Then I also would want to only use decrease and increase like so, so change name and reset will go.
Of course we are going to change this to a variable.
Same here, but we do need to import it first.
So maybe right after store I'm going to close my sidebar and then instead of all caps, I'm going to
go with import and then I'm importing decrease and then increase and not increase, but increase.
Weichsel, coming from the actions.
And then of course, I do need to reference the file.
So from DOT and then actions.
And once we have imported, then of course we're going to send this to a variable.
Now, I'm not going to use the local variable, even though, again, technically you could set this
up this way.
But again, what happens with actions just it just frees up the space.
So you're not clogging up your files that way, because in most cases there's more than just one action.
So I'm going to remove the decrease my local variable and instead of increased string, I'm going to
set this up as increased variable.
And the same thing, of course, I'm going to do here in the bottom where I'm dispatching the action
instead of using straight up string, we're going to use a variable that holds that string value.
And that way, of course, we can have less errors.
Let me delete all these strings like so and then I'm just going to reference my increased variable the
moment I served notice I have the value of three.
So the first one I decrease by one and then I increase four times.
That's the reason why I have three.
And again, the reason why you would want to set up your actions as a variable is because there is a
very easy to make a typo, especially if you're typing, I don't know, twenty thousand times throughout
your application.
But if you set it up as a variable and if you have the wrong reference, you're right away are going
to get there.
And as always, there is a bug as I'm typing.
It should be simple remove instead of the gibberish that I had here before.