Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,370 --> 00:00:03,880
We've got the template design loading in like we want it to.
2
00:00:03,910 --> 00:00:08,660
The next step is to make the app functional, but the question is where do we start?
3
00:00:08,680 --> 00:00:10,820
There are so many areas to cover.
4
00:00:10,840 --> 00:00:14,160
I always prefer to start with the user system.
5
00:00:14,170 --> 00:00:19,550
Most applications, regardless of their use, rely on a user system to work.
6
00:00:19,570 --> 00:00:22,930
You can't upload a song unless you know who's uploading it.
7
00:00:23,140 --> 00:00:25,330
It depends on the needs of your app.
8
00:00:25,330 --> 00:00:28,810
For this example, I think it would be a good starting point.
9
00:00:29,050 --> 00:00:33,780
In order to have users, we need to be able to store and manage users.
10
00:00:33,790 --> 00:00:37,150
We'll need to have a way to authenticate or register them.
11
00:00:37,270 --> 00:00:40,520
Authentication and registration is a good starting point.
12
00:00:40,540 --> 00:00:42,790
We'll begin with the user system.
13
00:00:43,150 --> 00:00:48,700
Before we begin coding the logic, we first need to understand something called State.
14
00:00:49,550 --> 00:00:53,670
The word state is a word that's thrown around a lot in the world of JavaScript.
15
00:00:53,690 --> 00:00:55,490
But what exactly does it mean?
16
00:00:55,520 --> 00:00:58,830
State refers to the data in the application.
17
00:00:58,850 --> 00:01:06,320
This can be data retrieved from a database or API data like a blog post product or media content.
18
00:01:06,560 --> 00:01:10,460
You can use the state to store application data too.
19
00:01:10,490 --> 00:01:14,900
There are certain types of data you wouldn't normally store in a database.
20
00:01:14,900 --> 00:01:19,130
However, they are still necessary for your app to function correctly.
21
00:01:19,160 --> 00:01:21,650
For example, a simple dropdown.
22
00:01:21,650 --> 00:01:27,360
If a user clicks on a dropdown button, then the contents of that dropdown should be shown.
23
00:01:27,380 --> 00:01:31,730
If they click away from that dropdown, then the content should be hidden.
24
00:01:31,850 --> 00:01:35,240
This is the type of data you would have to keep track of.
25
00:01:35,570 --> 00:01:40,020
Another example would be keeping track of the page the user is currently on.
26
00:01:40,040 --> 00:01:42,620
Are they on the home page or contact page?
27
00:01:42,620 --> 00:01:44,280
Depending on the URL.
28
00:01:44,300 --> 00:01:46,310
You would display different content.
29
00:01:46,700 --> 00:01:53,250
You provides one way of storing data by adding the data function to a component, while not wrong.
30
00:01:53,270 --> 00:01:57,530
It's considered good practice to have one single source of truth.
31
00:01:57,890 --> 00:02:03,030
All of this is considered the state of the application when you hear the word state.
32
00:02:03,050 --> 00:02:05,150
It's another way of saying data.
33
00:02:05,180 --> 00:02:11,150
It's data that is carefully kept track of while the application is live on a user's browser.
34
00:02:11,180 --> 00:02:15,740
If the user is on the home page, then you can call this the home state.
35
00:02:15,770 --> 00:02:20,190
If they're logging in, then you can call this the authentication state.
36
00:02:20,210 --> 00:02:24,470
It's used to describe what is currently happening in the application.
37
00:02:24,680 --> 00:02:28,120
So don't think of state as the data from the database.
38
00:02:28,130 --> 00:02:31,460
It's also the data that keeps track of the little things.
39
00:02:31,610 --> 00:02:33,020
The route this course.
40
00:02:33,020 --> 00:02:37,230
We've been using the data property as a way to keep track of things.
41
00:02:37,250 --> 00:02:44,360
The data property can be considered a way to store local state its data that only one component needs.
42
00:02:44,390 --> 00:02:49,140
However, what if we need to share data across multiple components?
43
00:02:49,160 --> 00:02:51,860
We need a way to have global state.
44
00:02:51,860 --> 00:02:56,300
Global state is when data is shared across multiple components.
45
00:02:56,570 --> 00:03:03,710
We have the option of passing down data to other components using prompts to send data back to the parent
46
00:03:03,710 --> 00:03:04,490
component.
47
00:03:04,520 --> 00:03:07,970
You could use a callback, function or image and events.
48
00:03:08,300 --> 00:03:14,360
In this example, let's say I had data that was used in child components B and C.
49
00:03:14,450 --> 00:03:20,260
Child component C is capable of updating the data to perform updates on data.
50
00:03:20,270 --> 00:03:25,730
We first have to pass down a callback function to child component A and then to C.
51
00:03:26,240 --> 00:03:32,060
Child component C can use the callback function to update the data inside the parent component.
52
00:03:32,390 --> 00:03:36,580
Lastly, the updated data would be sent to component B.
53
00:03:36,590 --> 00:03:38,890
This is the usual flow of data.
54
00:03:38,900 --> 00:03:44,150
It's what we've been doing up until now for a small to a medium sized application.
55
00:03:44,150 --> 00:03:45,470
This works fine.
56
00:03:45,500 --> 00:03:50,870
It's a bit annoying to have to pass down everything, but it's certainly doable and manageable.
57
00:03:51,110 --> 00:03:57,630
For larger applications, this process of managing global estate can become quite tedious very quickly.
58
00:03:57,650 --> 00:04:01,820
Imagine if you had ten layers of components in your application.
59
00:04:01,820 --> 00:04:05,810
That means you would have to pass down a callback function ten times.
60
00:04:05,810 --> 00:04:07,280
That isn't very fun.
61
00:04:07,550 --> 00:04:13,840
Luckily, Vue allows you to create your own library to manage state on a global level.
62
00:04:13,850 --> 00:04:15,760
We won't be going down that route.
63
00:04:15,770 --> 00:04:17,950
It's not necessary to do so.
64
00:04:17,959 --> 00:04:22,460
Instead, there are already libraries out there that will do this for us.
65
00:04:22,490 --> 00:04:25,790
The most popular solution is called Pernilla.
66
00:04:25,820 --> 00:04:30,020
Pernilla is a library for storing data in a central location.
67
00:04:30,050 --> 00:04:33,740
You won't have to pass it down from component to component.
68
00:04:33,950 --> 00:04:37,300
The state is directly accessible to all components.
69
00:04:37,310 --> 00:04:43,220
It doesn't matter how deeply nested your components are, the data can be retrieved or updated.
70
00:04:43,220 --> 00:04:46,930
Any changes to the data are reflected in all components.
71
00:04:46,940 --> 00:04:52,790
This means it's no longer necessary to pass down data through several children components.
72
00:04:52,820 --> 00:04:56,570
Data is handled in one centralized location.
73
00:04:56,630 --> 00:05:00,500
Fania is maintained by the core developers of Vue.
74
00:05:00,830 --> 00:05:03,910
You don't have to worry about compatibility issues.
75
00:05:03,920 --> 00:05:08,060
This is the library we'll be using for the rest of this course.
76
00:05:08,090 --> 00:05:11,180
There's one important point I want to stress.
77
00:05:11,180 --> 00:05:14,210
Centralised state is completely optional.
78
00:05:14,210 --> 00:05:15,980
Even if you have it installed.
79
00:05:15,980 --> 00:05:19,850
Sometimes you'll have data that will be used in a single component.
80
00:05:19,850 --> 00:05:25,040
If you don't plan on passing it down onto other components, you don't need to store it inside.
81
00:05:25,040 --> 00:05:29,690
These centralised state components can still have their own set of data.
82
00:05:29,690 --> 00:05:31,670
That's important to understand.
83
00:05:31,670 --> 00:05:33,710
You don't want to clutter your state.
8236
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.