1 00:00:00,500 --> 00:00:05,390 Awesome ones, we're familiar with our setup ones, roll up our sleeves and finally write some code 2 00:00:05,900 --> 00:00:11,720 and I guess we'll start by setting up our store and an excellent store is used to hold our data. 3 00:00:12,260 --> 00:00:17,720 Now, you can also think of a store as a single source of truth and a way for us to manage the state 4 00:00:17,900 --> 00:00:19,150 of our application. 5 00:00:19,760 --> 00:00:24,980 And in order to get up and running with the store, you'll need following three things create store 6 00:00:24,980 --> 00:00:30,680 function from the readers, a variable which will hold the value and then reduce their function. 7 00:00:31,070 --> 00:00:35,870 And I guess I'm going to start by peeling off the create store function from the redox. 8 00:00:36,110 --> 00:00:37,310 So let's write import. 9 00:00:38,280 --> 00:00:45,540 Then it is a name they import, so I need to use the curly braces, create store from, you guessed 10 00:00:45,540 --> 00:00:51,090 it, redacts, and then once we have imported the function now, we would want to set up the variable 11 00:00:51,210 --> 00:00:52,410 that will hold the value. 12 00:00:52,590 --> 00:00:56,580 And I can think of store as a place where we store our data. 13 00:00:56,820 --> 00:01:00,510 Now I'm going to name one store, but as always, you can call it Bugs Bunny. 14 00:01:00,540 --> 00:01:01,530 Doesn't really matter. 15 00:01:01,530 --> 00:01:02,790 It's just a variable name. 16 00:01:03,060 --> 00:01:06,810 But I'm going to go with store is equal create store. 17 00:01:07,080 --> 00:01:08,100 Let's invoke it. 18 00:01:08,250 --> 00:01:14,100 And if I say it without passing the register, you'll see that our application will blow up. 19 00:01:14,610 --> 00:01:19,800 The reason why our application goes up is because Great Store is looking for the argument and the argument 20 00:01:19,800 --> 00:01:22,260 it's looking for is the reducers function. 21 00:01:22,410 --> 00:01:30,180 And you can think of reducers function as a way for us to update our store, not just to emphasize that 22 00:01:30,180 --> 00:01:34,470 Reducer is a plain old JavaScript function as an argument. 23 00:01:34,470 --> 00:01:38,130 I'm just going to pass here, empty arrow function, say it. 24 00:01:38,130 --> 00:01:45,030 And as you can see now, my application works as expected and I will technically set up all our functionality 25 00:01:45,030 --> 00:01:45,600 right here. 26 00:01:45,960 --> 00:01:52,980 The problem with that approach is that the reducers normally hold quite a bit of code since all the 27 00:01:52,980 --> 00:01:54,600 store functionality is right there. 28 00:01:54,960 --> 00:02:01,110 So a more sane approach would be setting up a separate function and then just a reference that function. 29 00:02:01,350 --> 00:02:08,340 And as a side note, as our application will grow, we will move reducer to its own file altogether. 30 00:02:08,760 --> 00:02:11,280 So in my case, I'm going to create here comments. 31 00:02:11,280 --> 00:02:12,870 I'm going to write a register. 32 00:02:13,320 --> 00:02:15,450 Then, of course, you can write it as an arrow function. 33 00:02:15,780 --> 00:02:21,320 But I'm just going to pick a good old the regular JavaScript function as I and as far as the name I 34 00:02:21,390 --> 00:02:22,950 know, I'm going to go with reducer. 35 00:02:23,400 --> 00:02:25,380 No parameters for the time being. 36 00:02:25,620 --> 00:02:29,220 And then in the function body, I'm going to write a log. 37 00:02:30,030 --> 00:02:34,500 If you are very conservative, you can go with Hello World or Hello Redox. 38 00:02:34,860 --> 00:02:40,110 But since I feel like a rebel today, I'm going to go with Shake and Bake. 39 00:02:40,500 --> 00:02:42,480 And of course I do need to reference the function. 40 00:02:43,020 --> 00:02:44,960 Otherwise this does not make sense. 41 00:02:45,360 --> 00:02:50,130 So let me reference the function and then I can see that my application didn't blow up. 42 00:02:51,240 --> 00:02:57,630 And then also in the console I have shake and bake, which means that my producer is already to work.