Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,090 --> 00:00:06,630
In the previous lecture, we learned about mutations there a way to change a state property inside the
2
00:00:06,630 --> 00:00:07,290
store.
3
00:00:07,320 --> 00:00:11,850
Just like you can create mutations, you can create something called getters.
4
00:00:11,880 --> 00:00:14,190
Getters are exactly what they sound like.
5
00:00:14,190 --> 00:00:17,970
They allow you to access a state property from the store.
6
00:00:18,270 --> 00:00:20,100
Using a getter is optional.
7
00:00:20,100 --> 00:00:24,180
We can access the state property directly through the store object.
8
00:00:24,180 --> 00:00:27,500
The store object is injected into every component.
9
00:00:27,510 --> 00:00:30,480
Here's an example of how you would access the state.
10
00:00:30,480 --> 00:00:34,020
This is one way of grabbing a state property from the store.
11
00:00:34,050 --> 00:00:39,030
Peneha offers another solution for retrieving a state property called Getters.
12
00:00:39,030 --> 00:00:42,960
The main benefit of using a getter is the support for caching.
13
00:00:43,230 --> 00:00:47,070
It can intelligently update itself when the state changes.
14
00:00:47,220 --> 00:00:51,810
We've learned that the computed properties are one way to cache a value.
15
00:00:51,840 --> 00:00:57,870
One solution might be to write a computed property for every state property we'd like to use in a given
16
00:00:57,870 --> 00:00:59,730
component that would work.
17
00:00:59,730 --> 00:01:02,310
But then we would face duplication issues.
18
00:01:02,310 --> 00:01:06,420
We'd have to define the same computed properties in every component.
19
00:01:06,720 --> 00:01:08,370
That's where getters come in.
20
00:01:08,370 --> 00:01:12,030
You can think of getters as computed properties for your store.
21
00:01:12,030 --> 00:01:16,590
One of the main benefits of a getter is that they're accessible to all components.
22
00:01:16,590 --> 00:01:19,380
Define a getter once, use it everywhere.
23
00:01:19,410 --> 00:01:21,150
Getters are also smart.
24
00:01:21,150 --> 00:01:23,940
They will only update if the state changes.
25
00:01:23,940 --> 00:01:26,820
This can help with the performance of an application.
26
00:01:27,060 --> 00:01:31,410
Let's prepare our application for using a getter in the next lecture.
2453
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.