Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,060 --> 00:00:04,410
In this lecture, we're going to use penny hooks from within our components.
2
00:00:04,410 --> 00:00:09,540
Believe it or not, Peneha has vast support for the composition API.
3
00:00:09,570 --> 00:00:16,110
Most examples from the documentation will utilize the composition API over the options API.
4
00:00:16,140 --> 00:00:22,920
It's incredibly easy to use these state getters and actions from within a store to get started.
5
00:00:22,920 --> 00:00:29,580
Let's review the configuration for the store in our project inside the store's directory, open the
6
00:00:29,580 --> 00:00:31,500
counter JS file.
7
00:00:33,690 --> 00:00:39,090
Inside the store, we have a state property getter function and action function.
8
00:00:39,120 --> 00:00:46,570
The goal of this lecture is to use the state getter and action function from within the about component.
9
00:00:46,590 --> 00:00:50,020
We do not have to register peneha with the application.
10
00:00:50,040 --> 00:00:52,470
I have taken care of that step for you.
11
00:00:52,500 --> 00:00:54,600
Open the about component.
12
00:00:56,740 --> 00:00:58,150
At the top of the script.
13
00:00:58,150 --> 00:01:01,810
BLOCK We can import the store like we usually would.
14
00:01:03,920 --> 00:01:06,080
Next in the setup function.
15
00:01:06,080 --> 00:01:08,420
Define a variable called store.
16
00:01:08,450 --> 00:01:12,620
Its value will be the used counter store function.
17
00:01:14,760 --> 00:01:15,930
Just like that.
18
00:01:15,930 --> 00:01:19,170
We have access to the store from within the component.
19
00:01:19,200 --> 00:01:20,460
It's that simple.
20
00:01:20,490 --> 00:01:27,000
The store exported by the file will be a function we can call this function to gain access to the state
21
00:01:27,000 --> 00:01:30,660
properties, getters and actions from within the store.
22
00:01:30,690 --> 00:01:34,560
Let's try using these values at the end of the function.
23
00:01:34,560 --> 00:01:37,380
Return an object with the store variable.
24
00:01:39,560 --> 00:01:40,280
Next.
25
00:01:40,280 --> 00:01:43,340
Inside the templates, add a paragraph tag.
26
00:01:45,430 --> 00:01:49,180
Let's output the store counter property.
27
00:01:51,350 --> 00:01:53,630
Add another paragraph element.
28
00:01:55,650 --> 00:01:58,950
This time output the double count getter.
29
00:02:01,130 --> 00:02:04,280
Lastly, add a button with dummy text.
30
00:02:06,470 --> 00:02:11,690
On the button element at the Click Event Listener with the Prevent Modifier.
31
00:02:11,690 --> 00:02:16,310
If this event is triggered, we're going to run the increment action function.
32
00:02:18,440 --> 00:02:19,260
That's it.
33
00:02:19,280 --> 00:02:23,240
Let's try testing our work by refreshing the page in the browser.
34
00:02:25,320 --> 00:02:28,880
As you can see, the application is completely functional.
35
00:02:28,890 --> 00:02:32,430
We can press the button to run the increment action.
36
00:02:32,430 --> 00:02:36,540
As we do so, the state and getter properties are updated.
37
00:02:36,570 --> 00:02:43,140
Admittedly, using Peneha with the composition API is easier than using it with the options API.
38
00:02:43,170 --> 00:02:48,730
Previously we had to map these values with the composition API.
39
00:02:48,750 --> 00:02:52,440
It was simple as calling a function and returning the store.
40
00:02:52,470 --> 00:02:56,470
You may prefer the composition API over the options API.
41
00:02:56,490 --> 00:03:02,940
For this reason, in the next lecture, let's continue our discussion of the composition API.
3813
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.