All language subtitles for 022 Splitting Our Code_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
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
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,070 --> 00:00:04,550 Now to come to an end in this module 2 00:00:04,550 --> 00:00:07,270 where we learned a lot of important things. 3 00:00:07,270 --> 00:00:12,110 I wanna split up this index JS file into store folder. 4 00:00:12,110 --> 00:00:15,110 It's actually quite a small file 5 00:00:15,110 --> 00:00:17,950 not too much code in it, but of course, 6 00:00:17,950 --> 00:00:20,390 in your typical a React application 7 00:00:20,390 --> 00:00:22,710 where you have multiple state slices, 8 00:00:22,710 --> 00:00:25,780 this can become a very long file. 9 00:00:25,780 --> 00:00:28,160 So therefore it might be worth splitting it 10 00:00:28,160 --> 00:00:30,220 up into smaller pieces. 11 00:00:30,220 --> 00:00:32,400 And when using Redux Toolkit 12 00:00:32,400 --> 00:00:37,400 it could make sense to put every slice into its own file. 13 00:00:38,670 --> 00:00:41,960 So we could add a new file in the store folder 14 00:00:41,960 --> 00:00:46,520 and let's say the counter-slice.JS file 15 00:00:46,520 --> 00:00:50,253 or just counter.JS, the file name is up to you. 16 00:00:51,250 --> 00:00:52,860 And then we want to create 17 00:00:52,860 --> 00:00:57,410 and manage the counter specific state and slice in there. 18 00:00:57,410 --> 00:01:00,500 So we would grab the initial counter state 19 00:01:00,500 --> 00:01:04,440 and the entire counter slice cut that 20 00:01:04,440 --> 00:01:06,713 and add it into counter JS file. 21 00:01:08,399 --> 00:01:10,870 Now to use, create slice. 22 00:01:10,870 --> 00:01:13,620 We of course now need to import that here. 23 00:01:13,620 --> 00:01:18,620 So we import create slice from at Redux JS toolkit 24 00:01:20,090 --> 00:01:22,870 and we still also need to use counter slice 25 00:01:22,870 --> 00:01:24,480 in a different folder after. 26 00:01:24,480 --> 00:01:26,470 So we should export it. 27 00:01:26,470 --> 00:01:28,600 For example, as a default export 28 00:01:28,600 --> 00:01:30,253 we can export counter slice. 29 00:01:31,890 --> 00:01:33,970 Now we can do the same for off. 30 00:01:33,970 --> 00:01:38,050 So I'll add an off JS file and take my initial 31 00:01:38,050 --> 00:01:42,420 off state and D off slice cut debt 32 00:01:42,420 --> 00:01:46,830 from the index JS file and move it into off JS. 33 00:01:46,830 --> 00:01:49,712 And then also import create slice here 34 00:01:49,712 --> 00:01:53,003 from add to Redux Toolkit. 35 00:01:54,950 --> 00:01:59,950 And then also here export this default off slice. 36 00:02:02,080 --> 00:02:06,590 Now in index JS, we want to merge all those slices together. 37 00:02:06,590 --> 00:02:09,310 Therefore we can remove, create slice in there. 38 00:02:09,310 --> 00:02:11,220 We don't need that import anymore 39 00:02:11,220 --> 00:02:15,020 because we're not creating any slices in this file anymore. 40 00:02:15,020 --> 00:02:18,280 Instead, we focus on creating that main store 41 00:02:18,280 --> 00:02:20,713 and merging all the slice reducers together. 42 00:02:21,830 --> 00:02:26,830 Hence we can now import the counter slice 43 00:02:28,730 --> 00:02:33,360 from ./counter, or since we only really 44 00:02:33,360 --> 00:02:35,910 needed to reducer in here, we actually go 45 00:02:35,910 --> 00:02:40,450 to the counter and we just export the reducer. 46 00:02:40,450 --> 00:02:43,110 So we don't export the entire slice 47 00:02:43,110 --> 00:02:48,110 but just it's reducer part by doing that in index JS 48 00:02:48,110 --> 00:02:50,830 we could import the counter reducer here 49 00:02:50,830 --> 00:02:53,550 since that is what we're exporting as a default. 50 00:02:53,550 --> 00:02:55,120 And then just assign that 51 00:02:55,120 --> 00:03:00,120 as a reducer to counter the counter reducer 52 00:03:01,740 --> 00:03:03,900 and do the same for off the JS 53 00:03:03,900 --> 00:03:08,900 just export the reducer year and an index JS. 54 00:03:09,893 --> 00:03:13,700 Then therefore import the auth reducer 55 00:03:13,700 --> 00:03:18,380 from ./auth and assign this 56 00:03:18,380 --> 00:03:22,643 as a value for the auth key in that reducer map. 57 00:03:24,260 --> 00:03:26,050 Now regarding the actions, 58 00:03:26,050 --> 00:03:28,430 I want to export those from there, 59 00:03:28,430 --> 00:03:30,560 from the files into which they belong. 60 00:03:30,560 --> 00:03:34,240 So the counter actions should be exported here 61 00:03:34,240 --> 00:03:39,130 in the counter JS file still by accessing dot actions 62 00:03:39,130 --> 00:03:41,820 and exporting that as a named export 63 00:03:42,930 --> 00:03:45,700 at the same for auth I'll grab that export 64 00:03:45,700 --> 00:03:49,883 and index JS and move that into auth JS. 65 00:03:51,180 --> 00:03:52,013 Now with that, 66 00:03:52,013 --> 00:03:55,380 if we saved this we'll need to fix a couple of imports 67 00:03:55,380 --> 00:03:57,510 in counter JS for example, 68 00:03:57,510 --> 00:04:01,860 where I try to import counter actions from the index file 69 00:04:01,860 --> 00:04:04,607 we now need to import them from the counter file 70 00:04:04,607 --> 00:04:09,607 in the store folder in auth JS, we need to import 71 00:04:09,940 --> 00:04:14,940 auth the actions from the auth file in the store folder. 72 00:04:16,350 --> 00:04:18,140 In header, we need to import 73 00:04:18,140 --> 00:04:23,130 auth actions from the auth file as well 74 00:04:23,130 --> 00:04:26,570 and then user profile or not using anything of that. 75 00:04:26,570 --> 00:04:30,380 But if we now save that, if we reload, it works just as 76 00:04:30,380 --> 00:04:35,000 before all the state works as before 77 00:04:35,000 --> 00:04:36,530 but now we're splitting this up 78 00:04:36,530 --> 00:04:39,570 and in bigger application stat can ensure 79 00:04:39,570 --> 00:04:43,890 that our code stays maintainable and is easier to manage 80 00:04:43,890 --> 00:04:46,710 because now we have a lean index JS file 81 00:04:46,710 --> 00:04:51,090 and then pretty lean files for our different state slices 82 00:04:51,090 --> 00:04:52,170 which are then focused 83 00:04:52,170 --> 00:04:54,589 on one specific type of state, 84 00:04:54,589 --> 00:04:57,610 not required here but definitely helpful 85 00:04:57,610 --> 00:04:58,960 in bigger applications. 86 00:04:58,960 --> 00:05:01,583 And even here, it certainly doesn't hurt. 6769

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