All language subtitles for 16. Emitting Events to the Parent Component

af Afrikaans
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bn Bengali
bs Bosnian
bg Bulgarian
ca Catalan
ceb Cebuano
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
tl Filipino
fi Finnish
fr French Download
fy Frisian
gl Galician
ka Georgian
de German
el Greek
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
km Khmer
ko Korean
ku Kurdish (Kurmanji)
ky Kyrgyz
lo Lao
la Latin
lv Latvian
lt Lithuanian
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mn Mongolian
my Myanmar (Burmese)
ne Nepali
no Norwegian
ps Pashto
fa Persian
pl Polish
pt Portuguese
pa Punjabi
ro Romanian
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
st Sesotho
sn Shona
sd Sindhi
si Sinhala
sk Slovak
sl Slovenian
so Somali
es Spanish
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
te Telugu
th Thai
tr Turkish
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
or Odia (Oriya)
rw Kinyarwanda
tk Turkmen
tt Tatar
ug Uyghur
Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated: 1 00:00:00,210 --> 00:00:04,510 The last thing that we need to do is make this delete button functional. 2 00:00:04,740 --> 00:00:08,490 So when we click on it, it should delete that particular name. 3 00:00:09,030 --> 00:00:17,640 However, the issue that we have right now is that the delete button lives inside of the name Dot View. 4 00:00:18,150 --> 00:00:27,180 However, when we click on this, it needs to affect this array right over here which lives inside of 5 00:00:27,180 --> 00:00:29,010 the app dot view. 6 00:00:29,520 --> 00:00:33,180 So if this doesn't make more sense to you, let's look at a diagram. 7 00:00:33,510 --> 00:00:40,590 So right now the app to view it houses the array of selected names and then the name Dot View. 8 00:00:40,600 --> 00:00:43,550 It doesn't have any of those arrays. 9 00:00:43,710 --> 00:00:47,310 Instead it just has that one name that it is supposed to show. 10 00:00:47,790 --> 00:00:53,910 Now it has no reference to this array, and thus, how are we going to update it? 11 00:00:54,570 --> 00:00:57,090 Well, we can update it one of two ways. 12 00:00:57,810 --> 00:01:05,790 We can go ahead and pass that array to the name and then just go ahead and update it in there or what 13 00:01:05,790 --> 00:01:06,360 we can do. 14 00:01:06,360 --> 00:01:08,310 And this is probably a better idea. 15 00:01:08,640 --> 00:01:10,920 We can emit an event. 16 00:01:11,340 --> 00:01:17,760 So right inside of the app dot view, we can create this remove name functions, we can have this remove 17 00:01:17,760 --> 00:01:25,750 function and we can call this function any time the name Dot View emits a remove event. 18 00:01:26,160 --> 00:01:30,310 And once it emits this remove event, it's going to also pass in that name. 19 00:01:30,540 --> 00:01:37,170 We can catch that name inside of the parameter and then just remove that name entirely from the array. 20 00:01:37,830 --> 00:01:41,280 So let's actually go ahead and implement this. 21 00:01:42,120 --> 00:01:48,120 So let's actually go over here right to the card, dot card name. 22 00:01:48,510 --> 00:01:55,290 And what we want to do is we want to say that we are going to listen to a remove event. 23 00:01:55,830 --> 00:01:58,590 So right over here, we're going to say and remove. 24 00:01:59,580 --> 00:02:07,560 And as soon as you know, we emit error move event, I'm going to call a callback function that is going 25 00:02:07,560 --> 00:02:15,150 to call a function that we haven't created yet called remove name and then is also going to pass in 26 00:02:15,420 --> 00:02:18,360 the index of that particular element. 27 00:02:19,260 --> 00:02:25,950 So let's go over here and let's go all the way to the script and let's actually create that function. 28 00:02:26,790 --> 00:02:29,010 So let's go right over here. 29 00:02:29,010 --> 00:02:31,010 I think I think this is pretty good. 30 00:02:31,020 --> 00:02:34,590 Maybe, maybe right here, right below the actual state. 31 00:02:34,860 --> 00:02:38,450 We're going to create that remove name function. 32 00:02:39,450 --> 00:02:43,110 And then this is going to take in the index, of course. 33 00:02:43,230 --> 00:02:48,360 And this index, let's define it as a number, just for typescript sake. 34 00:02:49,290 --> 00:02:53,220 And now what we're going to do is we're going to say the filtered names. 35 00:02:53,670 --> 00:03:00,510 So what we want to do is we want to get basically all of the names except the name that lies in this 36 00:03:00,510 --> 00:03:01,110 index. 37 00:03:01,560 --> 00:03:04,240 So we can say filtered names is equal to. 38 00:03:04,560 --> 00:03:07,110 And we can say a brand new array. 39 00:03:07,860 --> 00:03:10,290 And we can say selected names dot value. 40 00:03:10,470 --> 00:03:15,900 So this is just basically structuring the current array into a brand new array. 41 00:03:16,380 --> 00:03:22,920 But then what we need to do now is very simply do a filtered name, dot splice. 42 00:03:23,840 --> 00:03:27,710 And then over here we're going to say add that particular index. 43 00:03:27,920 --> 00:03:28,760 And then one. 44 00:03:29,030 --> 00:03:31,070 So whatever this index is at. 45 00:03:31,370 --> 00:03:34,940 You want to essentially splice that out. 46 00:03:35,130 --> 00:03:38,630 And we just want to splice out one element at that index. 47 00:03:38,630 --> 00:03:41,960 So we're just going to splice out that particular index entirely. 48 00:03:42,470 --> 00:03:45,730 And then very simply, we're going to say selected names. 49 00:03:45,740 --> 00:03:50,450 Thought value is equal to filtered names. 50 00:03:50,900 --> 00:03:56,240 So that's really all it is that we need to do from the airport view side. 51 00:03:56,540 --> 00:03:58,850 There's one last thing that we also need to do. 52 00:03:59,030 --> 00:04:02,180 Right over here, we also need to pass the index. 53 00:04:02,660 --> 00:04:04,430 So right over here, we can say. 54 00:04:05,620 --> 00:04:06,580 Index. 55 00:04:07,240 --> 00:04:12,040 And then over here we can say index is equal to. 56 00:04:13,510 --> 00:04:16,330 So index is equal to index like so. 57 00:04:17,110 --> 00:04:17,680 Okay. 58 00:04:17,680 --> 00:04:19,240 So that's all it is that we need. 59 00:04:19,600 --> 00:04:22,820 And then inside of the name Dot View. 60 00:04:22,990 --> 00:04:26,920 Now what we need to do is start emitting events. 61 00:04:27,490 --> 00:04:29,530 So let's go ahead and do that. 62 00:04:30,370 --> 00:04:32,140 So right here, what we're going to say. 63 00:04:33,160 --> 00:04:39,820 Is concerned and then this is going to be emit is equal to the fine emits. 64 00:04:40,090 --> 00:04:45,480 So over here we're just going to define all of the different emissions that we can do now. 65 00:04:45,490 --> 00:04:50,650 Right now we can only do a remove event because that's exactly what we defined right over here. 66 00:04:51,100 --> 00:04:57,970 So we're going to say remove and then over here we're going to create another function. 67 00:04:57,970 --> 00:05:00,010 So we're going to call this remove name. 68 00:05:00,610 --> 00:05:05,500 And this function is very simply going to emit a remove event. 69 00:05:05,500 --> 00:05:09,340 So it's going to be we're going to call emit, we're going to say remove. 70 00:05:09,550 --> 00:05:14,680 And then as a parameter, we're going to pass in the props dot index. 71 00:05:15,010 --> 00:05:17,020 So let's go over here and actually define that. 72 00:05:17,020 --> 00:05:18,430 We also get an index. 73 00:05:18,910 --> 00:05:22,300 So over here we're going to say props dot index like. 74 00:05:22,300 --> 00:05:26,380 So now all that is that we need to do is right over here. 75 00:05:26,380 --> 00:05:32,670 We're going to say act click and we're just going to call the function remove name like so. 76 00:05:32,960 --> 00:05:35,500 So that's pretty much all it is that we need to do. 77 00:05:35,920 --> 00:05:38,110 So let's just give this a quick refresh. 78 00:05:39,550 --> 00:05:41,270 Let's just get a bunch of names here. 79 00:05:41,740 --> 00:05:45,910 And if we're not interested in them, as you can see now, they're getting deleted. 80 00:05:46,720 --> 00:05:49,960 So all these different names are getting deleted like so. 81 00:05:50,170 --> 00:05:53,950 Now, of course, we can click on it again and just get the names back and then delete them again. 82 00:05:54,280 --> 00:05:54,940 But that works. 83 00:05:54,940 --> 00:06:01,060 A Okay, so I hope you guys learned exactly how we can start emitting events, communicating from the 84 00:06:01,060 --> 00:06:06,200 child to the parents and actually manipulating the state there. 85 00:06:06,520 --> 00:06:10,660 And that is actually going to conclude our project. 86 00:06:10,660 --> 00:06:12,460 I hope you guys enjoyed it. 87 00:06:12,730 --> 00:06:16,600 And now let's actually go ahead and move on to bigger and better. 8353

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.