All language subtitles for 002 Redux & Side Effects (and Asynchronous 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
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,110 --> 00:00:03,500 Now let's start with 2 00:00:03,500 --> 00:00:05,872 looking at asynchronous code 3 00:00:05,872 --> 00:00:08,320 and side effects in general, 4 00:00:08,320 --> 00:00:09,911 even if they should be synchronous, 5 00:00:09,911 --> 00:00:14,390 even if the code should be synchronous, and Redux. 6 00:00:14,390 --> 00:00:17,190 Because there is one super important rule. 7 00:00:17,190 --> 00:00:19,001 Your reducer functions 8 00:00:19,001 --> 00:00:21,110 must be pure, 9 00:00:21,110 --> 00:00:23,930 side-effect free, and synchronous. 10 00:00:23,930 --> 00:00:26,967 So your reducer functions should take some input 11 00:00:26,967 --> 00:00:29,450 in the case of the Redux reducer, 12 00:00:29,450 --> 00:00:31,380 the old state and the action, 13 00:00:31,380 --> 00:00:33,494 and then produce some output. 14 00:00:33,494 --> 00:00:34,860 And that's, 15 00:00:34,860 --> 00:00:36,910 by the way not just the case for 16 00:00:36,910 --> 00:00:38,870 Redux reducer function. 17 00:00:38,870 --> 00:00:42,181 The reducer function you pass to use reducer, 18 00:00:42,181 --> 00:00:44,110 is react hook, 19 00:00:44,110 --> 00:00:45,570 works in the same way. 20 00:00:45,570 --> 00:00:47,930 It has nothing to do with redux, 21 00:00:47,930 --> 00:00:50,923 but it just general reducer concept 22 00:00:50,923 --> 00:00:52,564 that you have a pure, 23 00:00:52,564 --> 00:00:54,865 side effects synchronous function 24 00:00:54,865 --> 00:00:56,384 that takes input and 25 00:00:56,384 --> 00:00:58,082 produces some output. 26 00:00:58,082 --> 00:00:59,910 And for the same input, 27 00:00:59,910 --> 00:01:01,010 for the same values, 28 00:01:01,010 --> 00:01:04,029 it will always produce the same output, 29 00:01:04,029 --> 00:01:07,306 without any side effects that happen along the way 30 00:01:07,306 --> 00:01:11,200 without any asynchronous code that blocks it. 31 00:01:11,200 --> 00:01:14,780 No code of that kind must be part of your 32 00:01:14,780 --> 00:01:16,197 reducer functions. 33 00:01:16,197 --> 00:01:19,465 But of course, that brings up an important question 34 00:01:19,465 --> 00:01:21,127 when working with redux, 35 00:01:21,127 --> 00:01:23,530 when we dispatch some action 36 00:01:23,530 --> 00:01:25,280 that would involve a side effect, 37 00:01:25,280 --> 00:01:27,808 like HTTP request that should be sent, 38 00:01:27,808 --> 00:01:30,040 where should we then put 39 00:01:30,040 --> 00:01:31,706 the side effect code? 40 00:01:31,706 --> 00:01:35,390 Where should we put our asynchronous code 41 00:01:35,390 --> 00:01:37,300 when working with redux? 42 00:01:37,300 --> 00:01:38,726 Because the reducer function 43 00:01:38,726 --> 00:01:40,404 is clearly the wrong place 44 00:01:40,404 --> 00:01:42,840 as we just learned. 45 00:01:42,840 --> 00:01:44,690 The answer to this question is 46 00:01:44,690 --> 00:01:46,727 that we have two possible places 47 00:01:46,727 --> 00:01:49,336 where we can put our side effects. 48 00:01:49,336 --> 00:01:52,280 We can put our side effects 49 00:01:52,280 --> 00:01:54,308 possibly asynchronous code 50 00:01:54,308 --> 00:01:56,449 directly into the component 51 00:01:56,449 --> 00:01:59,420 with user fact for example, 52 00:01:59,420 --> 00:02:02,760 so just as we did it before in this course, 53 00:02:02,760 --> 00:02:05,530 and then we only dispatch an action 54 00:02:05,530 --> 00:02:08,020 once that side effect is done 55 00:02:08,020 --> 00:02:11,869 so Redux doesn't know anything about that side effect, 56 00:02:11,869 --> 00:02:13,090 or, and 57 00:02:13,090 --> 00:02:14,494 that will be new 58 00:02:14,494 --> 00:02:19,030 we write our own action creator functions, 59 00:02:19,030 --> 00:02:22,170 so we don't use the automatically generated ones 60 00:02:22,170 --> 00:02:24,000 redux toolkit gives us 61 00:02:24,000 --> 00:02:26,523 but instead we write our own action creators. 62 00:02:26,523 --> 00:02:28,830 And it turns out that 63 00:02:28,830 --> 00:02:30,562 for those action creators 64 00:02:30,562 --> 00:02:33,160 redux actually has a solution 65 00:02:33,160 --> 00:02:34,300 that allows us to 66 00:02:34,300 --> 00:02:35,980 perform side effects 67 00:02:35,980 --> 00:02:40,980 and run asynchronous tasks as part of this action creators 68 00:02:41,500 --> 00:02:43,890 without changing the reducer function 69 00:02:43,890 --> 00:02:47,590 because that function must stay side effect free. 70 00:02:47,590 --> 00:02:49,570 Now we are going to have a look at both 71 00:02:49,570 --> 00:02:51,690 approaches in this course 72 00:02:51,690 --> 00:02:52,582 section, 73 00:02:52,582 --> 00:02:53,415 And 74 00:02:53,415 --> 00:02:54,770 to have a look at that, 75 00:02:54,770 --> 00:02:56,018 We are going to start 76 00:02:56,018 --> 00:02:57,321 by setting up another 77 00:02:57,321 --> 00:02:59,595 React-Redux application. 78 00:02:59,595 --> 00:03:02,340 We are going to do that in the next 79 00:03:02,340 --> 00:03:04,560 two lectures and you can therefore 80 00:03:04,560 --> 00:03:06,320 skip those two lectures 81 00:03:06,320 --> 00:03:07,780 if you don't wanna repeat 82 00:03:07,780 --> 00:03:10,060 what you learnt in the last course section, 83 00:03:10,060 --> 00:03:12,840 though I of course recommend that you don't. 84 00:03:12,840 --> 00:03:14,310 But we are going to repeat that 85 00:03:14,310 --> 00:03:16,680 build a basic react-redux application 86 00:03:16,680 --> 00:03:18,180 in the next two lectures 87 00:03:18,180 --> 00:03:20,130 and there after we're going to 88 00:03:20,130 --> 00:03:22,060 explore asynchronous code 89 00:03:22,060 --> 00:03:22,910 and redux 90 00:03:22,910 --> 00:03:25,243 and all this shiny new things. 6168

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