Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,150 --> 00:00:06,100
In this lecture, we're going to review the configuration for the Pineal library in our project.
2
00:00:06,120 --> 00:00:09,900
Generally, the first step is to install the package.
3
00:00:09,900 --> 00:00:12,420
Luckily, we can skip this step.
4
00:00:12,420 --> 00:00:19,320
The Create View package installed this package for us just in case you may need to install this package
5
00:00:19,320 --> 00:00:20,130
manually.
6
00:00:20,130 --> 00:00:23,820
You can run the NPM install pin command.
7
00:00:23,820 --> 00:00:28,140
After installing this package, we must register it as a plug in.
8
00:00:28,140 --> 00:00:31,500
Let's stop for a moment and talk about plug ins.
9
00:00:33,560 --> 00:00:36,410
Plug ins are precisely what they sound like.
10
00:00:36,440 --> 00:00:40,290
The new applications can be extended with additional features.
11
00:00:40,310 --> 00:00:46,770
You will most likely download third party libraries to assist you with developing your application.
12
00:00:46,790 --> 00:00:52,430
View provides a way for other libraries to extend it by providing a plug in API.
13
00:00:52,460 --> 00:00:54,760
Plug ins can do almost anything.
14
00:00:54,770 --> 00:01:00,170
They can add directives, register components and even provide another API.
15
00:01:00,320 --> 00:01:04,260
There are two steps to installing a plug in in our project.
16
00:01:04,280 --> 00:01:06,470
First, we need to import it.
17
00:01:06,500 --> 00:01:09,020
Second, we need to register it.
18
00:01:11,530 --> 00:01:16,030
Every plugin must be registered before the Vue instance is created.
19
00:01:16,060 --> 00:01:21,050
Otherwise we might not have access to every feature a plugin provides.
20
00:01:21,070 --> 00:01:23,890
Let's open the main JS file.
21
00:01:26,040 --> 00:01:29,720
The file scaffolded by view is different from before.
22
00:01:29,790 --> 00:01:34,800
In between the Create App and Mount functions, there's additional code.
23
00:01:34,800 --> 00:01:39,390
Registering plug ins must be performed before mounting the instance.
24
00:01:39,480 --> 00:01:43,840
The used method allows us to register a plug in from there.
25
00:01:43,860 --> 00:01:47,550
It's the responsibility of the plugin to extend view.
26
00:01:47,730 --> 00:01:53,250
Registering a plugin is as simple as passing an object to the use function.
27
00:01:53,400 --> 00:01:58,740
In this case, two plugins are being registered called Rooter and Store.
28
00:01:58,770 --> 00:02:01,600
We're going to ignore the router object.
29
00:02:01,620 --> 00:02:04,050
It'll be discussed in another lecture.
30
00:02:04,080 --> 00:02:08,009
Let's put our focus on the create a function.
31
00:02:08,039 --> 00:02:13,050
This function will return an object compatible with Vue's plugin API.
32
00:02:13,080 --> 00:02:17,310
The question is what is Peneha doing behind the scenes?
33
00:02:17,340 --> 00:02:21,720
Peneha is registering a plugin with the Vue developer tools.
34
00:02:21,720 --> 00:02:24,670
The developer tools are completely extendable.
35
00:02:24,690 --> 00:02:29,700
The Peneha package will add a new tool for interacting with the state.
36
00:02:29,730 --> 00:02:34,020
If you want help with debugging, you should always register the plugin.
37
00:02:34,050 --> 00:02:37,790
Let's check out the plugin, switch over to the browser.
38
00:02:37,800 --> 00:02:40,440
Open the view developer tools.
39
00:02:42,610 --> 00:02:46,600
Under the inspector section, we can switch to a different tool.
40
00:02:46,600 --> 00:02:50,170
As you can see, Piniella is listed as an option.
41
00:02:50,170 --> 00:02:54,640
We can select this option to view the data from our application.
42
00:02:54,640 --> 00:02:57,060
At the moment it's going to be empty.
43
00:02:57,070 --> 00:03:01,420
We haven't taken the time to register state with our application.
44
00:03:01,420 --> 00:03:03,820
Let's head back to our editor's.
45
00:03:05,930 --> 00:03:11,540
Inside the source directory, there's a folder called stores before proceeding.
46
00:03:11,540 --> 00:03:14,960
Let's understand why it's being called stores.
47
00:03:17,050 --> 00:03:21,210
When learning state management, the terminology is half the battle.
48
00:03:21,220 --> 00:03:24,510
The word store is short for storage.
49
00:03:24,520 --> 00:03:27,100
We can think of stores as warehouses.
50
00:03:27,130 --> 00:03:29,740
A warehouse can store various items.
51
00:03:29,740 --> 00:03:34,420
We may store food, furniture or common household items.
52
00:03:34,420 --> 00:03:39,280
It's common for warehouses to be subdivided into specific sections.
53
00:03:39,280 --> 00:03:44,290
Food can be put in one section, while furniture can be put in another section.
54
00:03:44,320 --> 00:03:48,760
Otherwise, you're going to be running all over the place searching for items.
55
00:03:48,790 --> 00:03:52,090
This same idea applies to state management.
56
00:03:52,090 --> 00:03:55,300
We can think of our data being put into a warehouse.
57
00:03:55,300 --> 00:03:59,020
We may have different storages for different types of data.
58
00:03:59,020 --> 00:04:04,390
For example, you may have a store for users and a store for blog posts.
59
00:04:07,100 --> 00:04:12,660
In our Project View recommends defining your stores inside this directory.
60
00:04:12,680 --> 00:04:16,839
It's not mandatory, but recommend it for the rest of this course.
61
00:04:16,850 --> 00:04:19,450
We're going to adhere to this practice.
62
00:04:19,459 --> 00:04:23,750
Inside this folder there's a file called Counter JS.
63
00:04:23,780 --> 00:04:26,630
Let's open it inside this file.
64
00:04:26,630 --> 00:04:31,700
A function called Define Store is imported from the Penney package.
65
00:04:31,700 --> 00:04:35,000
This function will create a special type of object.
66
00:04:35,000 --> 00:04:39,140
The object created by this function will have its data tracked.
67
00:04:39,170 --> 00:04:43,220
Penney is meant to be used globally, which can make things tricky.
68
00:04:43,220 --> 00:04:45,980
Multiple components can change the data.
69
00:04:45,980 --> 00:04:52,070
It's important to keep track of those changes, determine which change should be applied and what to
70
00:04:52,070 --> 00:04:53,840
send to other components.
71
00:04:54,050 --> 00:04:56,900
Peneha can handle this sort of task easily.
72
00:04:56,900 --> 00:05:02,210
Any time a change occurs in your state, every component will be notified of the updates.
73
00:05:02,240 --> 00:05:06,170
It'll make sure every component is in sync with the state.
74
00:05:06,170 --> 00:05:11,330
Since changes are tracked, you will have an easier time debugging your application.
75
00:05:11,330 --> 00:05:13,790
This is why we have to call this method.
76
00:05:13,790 --> 00:05:17,390
It creates a special object for keeping track of state.
77
00:05:17,510 --> 00:05:20,390
The object is exported from our script.
78
00:05:20,390 --> 00:05:22,490
Before the object is created.
79
00:05:22,490 --> 00:05:28,130
We're passing in three additional objects called state getters and actions.
80
00:05:28,130 --> 00:05:32,030
Each property will be explored as the course progresses.
81
00:05:32,030 --> 00:05:32,900
That's it.
82
00:05:32,900 --> 00:05:37,160
We've successfully introduced state management into our project.
83
00:05:37,160 --> 00:05:39,770
We can begin to use it for this course.
84
00:05:39,770 --> 00:05:42,200
We're not going to need the counter store.
85
00:05:42,230 --> 00:05:47,480
This example is to demonstrate how a store can be created in future lectures.
86
00:05:47,480 --> 00:05:50,510
We're going to create store files from scratch.
87
00:05:50,510 --> 00:05:52,340
Let's delete this file.
88
00:05:54,410 --> 00:05:59,000
Once you've deleted the file, let's start creating custom stores.
89
00:05:59,000 --> 00:06:02,940
In the next set of lectures, we'll start writing some code.
90
00:06:02,960 --> 00:06:04,190
I'll see you there.
8440
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.