All language subtitles for 002 Registering a Plugin_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
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
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French Download
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu
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:01,020 In this lecture. 2 00:00:01,020 --> 00:00:06,080 The next step is to register the validation library we installed in our project. 3 00:00:06,090 --> 00:00:08,430 There are two ways we can approach this. 4 00:00:08,430 --> 00:00:11,340 We can register it locally or globally. 5 00:00:11,370 --> 00:00:16,560 The approach you'll want to use depends on how often you plan on using validation. 6 00:00:16,890 --> 00:00:23,100 If you're going to use validation for one or two forms, registering it locally is the way to go. 7 00:00:23,100 --> 00:00:25,920 However, we'll be using it more than once. 8 00:00:25,920 --> 00:00:28,710 Registering it globally is the way to go. 9 00:00:28,920 --> 00:00:33,420 One problem with this approach is how much configuration will have to deal. 10 00:00:33,530 --> 00:00:41,070 Validate is a very powerful library because validation varies from form to form, it's able to accommodate 11 00:00:41,070 --> 00:00:42,450 most scenarios. 12 00:00:42,450 --> 00:00:46,110 We'll be writing a lot of code for configuring this library. 13 00:00:46,110 --> 00:00:51,960 We don't want to clutter the code inside the main JS file with too much configuration. 14 00:00:51,960 --> 00:00:54,420 We want to keep it as light as possible. 15 00:00:54,570 --> 00:00:59,570 We'll outsource the configuration in a separate file by creating a custom plugin. 16 00:00:59,580 --> 00:01:04,379 Up until now, we've been installing libraries that come bundled us plugins. 17 00:01:04,379 --> 00:01:07,560 We registered plugins by using the use function. 18 00:01:07,560 --> 00:01:12,420 On the view instance, we can create a custom plugin to extend view. 19 00:01:12,780 --> 00:01:18,870 Let's try creating a custom one for registering validate inside the source directory. 20 00:01:18,870 --> 00:01:21,630 We'll create a folder called includes. 21 00:01:23,870 --> 00:01:27,500 This directory is where we'll define our custom plugins. 22 00:01:27,530 --> 00:01:32,990 In some projects there are developers who will use the name plugins for their directory. 23 00:01:33,200 --> 00:01:38,850 We're using a different naming convention because we'll be placing non plugin files in this directory. 24 00:01:38,870 --> 00:01:45,950 If you want, feel free to further organize the project by creating a directory called plugins exclusively 25 00:01:45,950 --> 00:01:47,370 for plugin files. 26 00:01:47,390 --> 00:01:51,080 We will keep it simple by having one directory for everything. 27 00:01:51,380 --> 00:01:57,170 Inside this directory will create a file called Validation JS. 28 00:01:59,370 --> 00:02:00,720 Inside the file. 29 00:02:00,720 --> 00:02:05,730 We'll create a plugin by exporting an object under the default namespace. 30 00:02:08,020 --> 00:02:11,350 The object will have one method called install. 31 00:02:13,720 --> 00:02:19,960 Plugins are objects with a method called install if you will call the install method when we register 32 00:02:19,960 --> 00:02:20,290 it. 33 00:02:20,320 --> 00:02:21,790 Let's do that next. 34 00:02:21,790 --> 00:02:27,970 And the main JS file will import the plug in under the name V validate plug in. 35 00:02:31,380 --> 00:02:38,250 Next we'll call the use function below the other use functions we'll pass in our custom plugin. 36 00:02:40,570 --> 00:02:45,830 Before of you mounts our application, it'll run the install method in our plugin. 37 00:02:45,850 --> 00:02:49,960 Inside the install method, we are allowed to do anything we want. 38 00:02:49,960 --> 00:02:56,740 We can register components, directives, etc. there are two arguments we can accept in the install 39 00:02:56,740 --> 00:02:57,720 method there. 40 00:02:57,730 --> 00:03:00,460 The app and options arguments. 41 00:03:02,620 --> 00:03:06,220 The EP argument is a reference to the View application. 42 00:03:06,220 --> 00:03:11,950 We have access to the same methods and properties we would normally encounter on The View, and since 43 00:03:11,950 --> 00:03:18,460 the options argument is additional data passed from the view instance to the plugin back in the main 44 00:03:18,670 --> 00:03:19,690 JS file. 45 00:03:19,720 --> 00:03:26,110 The use function has a second optional parameter we can pass in an object that we would like to provide 46 00:03:26,110 --> 00:03:26,980 the plugin. 47 00:03:27,010 --> 00:03:31,180 For example, I'll pass in an object with a random property. 48 00:03:33,520 --> 00:03:38,170 The object will be the value for the second argument in the install function. 49 00:03:38,200 --> 00:03:44,620 Typically, developers use this to allow other developers to configure how the plugin will function. 50 00:03:44,650 --> 00:03:46,870 It varies from plugin to plugin. 51 00:03:46,870 --> 00:03:51,640 So far we haven't had to configure any of the plugins we've installed. 52 00:03:51,640 --> 00:03:54,940 We won't need this parameter for our project. 53 00:03:54,940 --> 00:03:58,570 This custom plugin is exclusively for this project. 54 00:03:58,600 --> 00:04:01,450 We'll be removing its use in both files. 55 00:04:03,640 --> 00:04:05,560 Back to the task at hand. 56 00:04:05,590 --> 00:04:09,780 In the validation file, we're going to register two components. 57 00:04:09,790 --> 00:04:13,130 First, we'll import them at the top of the file. 58 00:04:13,150 --> 00:04:20,079 We'll import two components from the validate package there, the form and field components. 59 00:04:22,390 --> 00:04:27,280 The components we're importing were specifically designed to help us validate a form. 60 00:04:27,280 --> 00:04:30,390 We'll learn how they'll help us in upcoming lectures. 61 00:04:30,400 --> 00:04:36,580 We're going to register the components globally because we'll be performing validation on various forms 62 00:04:36,580 --> 00:04:37,480 in our app. 63 00:04:37,870 --> 00:04:40,930 There is one problem with the name of the components. 64 00:04:40,930 --> 00:04:43,660 There's already an element with the name form. 65 00:04:43,660 --> 00:04:46,930 We don't want to cause conflicting issues in our app. 66 00:04:46,930 --> 00:04:52,090 We'll rename the components in the import statement by using the as keyword. 67 00:04:52,090 --> 00:04:55,390 We'll rename the form component to the form. 68 00:04:57,660 --> 00:05:01,470 The field component will be renamed to the fields. 69 00:05:03,710 --> 00:05:05,510 Inside the install method. 70 00:05:05,510 --> 00:05:08,870 We'll register both components with the component function. 71 00:05:13,170 --> 00:05:14,230 We're finished. 72 00:05:14,250 --> 00:05:16,290 Let's test if everything is working. 73 00:05:16,320 --> 00:05:18,780 If you haven't already, turn on the server. 74 00:05:18,780 --> 00:05:20,370 View the app in the browser. 75 00:05:22,680 --> 00:05:24,490 Everything should still be working. 76 00:05:24,510 --> 00:05:26,850 There shouldn't be any errors in the console. 77 00:05:26,880 --> 00:05:27,810 Congrats. 78 00:05:27,810 --> 00:05:31,280 We've successfully installed the validate library. 79 00:05:31,290 --> 00:05:33,840 We can proceed with form validation. 7527

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