All language subtitles for 009 Using the Custom Store_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
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 Download
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:02,350 --> 00:00:08,470 So to use that custom store, let's go to the index, Jaspal, and get rid of the products provider, 2 00:00:08,500 --> 00:00:13,900 which is our context API in action, can we get rid of that and instead import? 3 00:00:15,490 --> 00:00:17,260 Configures story from. 4 00:00:22,840 --> 00:00:28,180 Hooks Store Products store and called that here to set up our store. 5 00:00:29,020 --> 00:00:33,090 Now the cool thing is we don't need to wrap this in a provider component or anything like that. 6 00:00:33,490 --> 00:00:41,770 This will make sure that we initialize our store since we import in its store from the store fol these 7 00:00:41,770 --> 00:00:46,900 things here will all be set up and they will be initialized with the values we're passing in our product 8 00:00:46,910 --> 00:00:47,200 store. 9 00:00:47,200 --> 00:00:53,320 Jaspal, if we had multiple stores, we would simply call Configures store for these different stores. 10 00:00:53,320 --> 00:00:55,450 You would just have to give these functions different names. 11 00:00:55,540 --> 00:00:59,980 You can, for example, named as Configure Products Store, of course, because it's the default export 12 00:00:59,980 --> 00:01:01,270 you can name is whatever you want. 13 00:01:01,600 --> 00:01:06,400 And you would call all these configure store functions for all the different store parts you might have 14 00:01:06,400 --> 00:01:06,970 in your app. 15 00:01:07,330 --> 00:01:10,860 And with that, the store is ready to use now to use it. 16 00:01:11,440 --> 00:01:16,570 We can simply go to the place where we need it, like here, the products container file. 17 00:01:17,080 --> 00:01:24,520 Instead of importing our context there, we can import use stores are custom hook from. 18 00:01:25,470 --> 00:01:31,260 Hook store store now, so not from the product store, but just store and you store, it gives us access 19 00:01:31,260 --> 00:01:34,030 to the global store and the global dispatch function. 20 00:01:34,710 --> 00:01:38,160 So now here we can call use store. 21 00:01:40,220 --> 00:01:41,760 Don't need to pass anything there. 22 00:01:42,110 --> 00:01:43,610 And when we get back is our. 23 00:01:44,530 --> 00:01:48,790 State and a dispatch function, that's what we get back from use store. 24 00:01:50,090 --> 00:01:55,730 Now, of course, here I'm not interested in the dispatch function, so I can simply just get my state 25 00:01:55,730 --> 00:02:00,590 here by just accessing the first element returned by the customs to work at a custom hook because the 26 00:02:00,590 --> 00:02:04,850 custom returns to things local, state and dispatch the only need to state. 27 00:02:04,850 --> 00:02:09,060 We just extract the first element from the array with this syntax, of course. 28 00:02:09,560 --> 00:02:10,550 So that's our state. 29 00:02:11,150 --> 00:02:16,850 And therefore here we can output state products because we know there will be a product's key in our 30 00:02:16,850 --> 00:02:19,730 state because that's what we're setting up in the products store. 31 00:02:19,730 --> 00:02:26,810 Jaspal, when we initialize our state, then here, the second argument we pass to in its store is our 32 00:02:26,810 --> 00:02:27,170 object. 33 00:02:27,170 --> 00:02:29,810 But we add a product that is. 34 00:02:30,780 --> 00:02:35,880 What will be initialised, second argument, as our initial statehood will be merged with the global 35 00:02:35,880 --> 00:02:40,680 state and therefore the global state will have a product's key, and that's what I'm accessing here 36 00:02:41,250 --> 00:02:47,160 now to test this, let's go to the product item and get rid of our context thing there, because that 37 00:02:47,160 --> 00:02:48,240 won't work right now. 38 00:02:49,280 --> 00:02:52,670 Get rid of this and comment this out and save that. 39 00:02:54,590 --> 00:02:58,280 And if you reload this page, you you should still see all your products there. 40 00:02:58,880 --> 00:03:01,030 Now let's make the favorite button work again. 41 00:03:01,430 --> 00:03:07,280 And for this in the product item file, instead of importing use context, we can import. 42 00:03:08,500 --> 00:03:09,730 Use store. 43 00:03:14,010 --> 00:03:14,580 From. 44 00:03:17,170 --> 00:03:20,920 The Hooke's store folder and their disgorges file. 45 00:03:22,070 --> 00:03:26,570 And then here, recall call use store, and now I'm only interested in the dispatch function, which 46 00:03:26,570 --> 00:03:32,900 is our second argument, we'd return in our store here, we return to the rate dispatch is the second 47 00:03:32,900 --> 00:03:35,510 argument or the second element, I should say. 48 00:03:35,750 --> 00:03:37,790 So I'm extracting that second element here. 49 00:03:38,180 --> 00:03:40,790 That's the dispatch function. 50 00:03:41,960 --> 00:03:49,310 So I saw it in this dispatch constant, we can call dispatch here and now what I want to dispatch is 51 00:03:49,310 --> 00:03:57,770 an actual identifier, which is toggle Faf and will then look for such an identifier in our actions 52 00:03:57,770 --> 00:04:01,490 map, which I set up in products store there. 53 00:04:02,060 --> 00:04:06,830 This is the actions map, which I use to initialize my store, which will be merged into the global 54 00:04:06,830 --> 00:04:07,610 action map. 55 00:04:07,610 --> 00:04:13,160 And there I have toggle Faf as an identifier and this needs a payload of product ID, which is good 56 00:04:13,160 --> 00:04:15,800 to know because that's the second argument we can forward here. 57 00:04:15,920 --> 00:04:20,120 Perhaps ID that should be all with that change. 58 00:04:21,269 --> 00:04:23,400 Now we can mark things as a favorite again. 59 00:04:24,000 --> 00:04:28,610 Now let's make sure the favorites page works again, because right now it's not working. 60 00:04:28,620 --> 00:04:32,520 Of course, even though I have favorites, because it still tries to get them from the context. 61 00:04:33,090 --> 00:04:35,180 So in the favorites, just fall here. 62 00:04:35,220 --> 00:04:37,100 Let's not import the context anymore. 63 00:04:37,440 --> 00:04:40,890 But again, import use store from. 64 00:04:43,320 --> 00:04:51,480 The bookstore store folder and there it is, store Jaspal, and then here we got our state, which is 65 00:04:51,480 --> 00:04:59,100 use store, and they're the first element and I'm interested in my favorite products, which I get by 66 00:04:59,100 --> 00:05:00,850 accessing state products. 67 00:05:02,750 --> 00:05:08,180 State products don't filter, and then I search for all products which are. 68 00:05:09,220 --> 00:05:11,830 A favorite like this. 69 00:05:13,020 --> 00:05:18,810 So, yeah, by the way, make sure you, of course, execute your custom hook that's important at parentheses 70 00:05:18,810 --> 00:05:20,860 here, safeness and give it a try. 71 00:05:20,910 --> 00:05:22,760 Got no products yet after the reload. 72 00:05:22,770 --> 00:05:25,580 But now let's add two and we see them here. 73 00:05:26,370 --> 00:05:28,440 So this is now working. 74 00:05:28,620 --> 00:05:34,170 And I'm totally aware that this is kind of hard to wrap your head around it first. 75 00:05:34,740 --> 00:05:38,550 So let me summed it up by briefly going through that again in the next lecture. 7675

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