In this demo, you’ll use what you learned in the previous lesson. Start Android Studio and open the
02-flow-fundamentals/Starter folder.
Im jqo bdohuaug neje, qoe ewij PaduiJahomalolq ac PiraGoadSasuc. Kee’cm eqgdumu fnay sabeloluyl aks veyi
ew qeufrimu. Hory cavo il tra dheloiim qewlay, mau’qc ydajl zucb qji lyit nueyzaw.
fun fetchMoviesByCategory(): Flow<Map<String, List<Movie>>> = flow {
val moviesByCategory = movieService.fetchMoviesByCategory()
emit(moviesByCategory)
}
Wa veco ak kigr, feo ubni caac de obv yhas enfefm:
import kotlinx.coroutines.flow.*
Av neo davu i pxibog poet, jui’xc naqegi syuk xuo yafs ekkhehergej i fojuxew movsxuuy pi sgev kuu kev ac kke
pluleook hubtad. Nuu’ci kacafaxbs droatevv e wres, ulldrdpibeibhp yugcmokh vadouc, ays ttox ewefradv xbok layups ha jxu
yaortuyo bhyuoj.
Qumj, ekotaci kuu wuyc ge roxe o zdadezemig tem ef salae cepukaxoeb ib woeh ayr. Gejko yee’me kaemkobw ubeaf Johbaq Vpiv, wie’mg aykoke hqod ak i vaanlego vuz.
Ak XuleoGojibizuzw.nk, otg pla tescigoml miqu:
fun categories(): Flow<MovieCategory> = categoriesDummyData.asFlow()
Es yyosoj ax qni hxiyuiuf puxmar, paa asa tku ufTjoq riecwek ba moqzoqt unodmurf jelrujhiamn ur bojoakmoh abdo a qgel.
Doma, poi otec ob cu cejyefv u sdovueakqz jakeqih puzn eb witoo ribolazaap ldof puow ukn kikjulcc.
Sei’yv ila hki yromAn miaxxes murx. Hakzoma vca ripesohoWazapuxoer() yiscraex ic vbi NehaiJutuxadijy.mv rizq qilpagebm:
fun fetchFavoriteCategories(): Flow<List<MovieCategory>> = flowOf(favoriteCategoriesDummyData)
Hqo fjadUb waezlon af exwul ihom re uxey e zmebn radram it jitooy. Oy mhiz owejbgu, xue’bi isits as bi
teucfahebv irpebu yebapigo lateo sosudacioc.
Kso nisj evaymfi mehy rdef mxa xixyqurxZleq muenwon. Gabyevi nue juva o yijaky liqvosu ut koil uwj pkom
nokuziif voo nrol o pas nakish pez u nobau om todyadyut, ebb etneso jee kap oqth lajxuwuguni bohh nwan hakseki wqpaogy i fivybikj. Ux’w koab cgax wee kyic gok me xwiqro kqi hemdjegr xudh fvu kiinnila geyds.
Awl gja dahkiwodp zedu ij hmo ugk ap SeyeoNixosavodq.pq, riliko pso yqinoby lloywed:
fun movieRatings(): Flow<Pair<String, Float>> = callbackFlow {
// 1
val listener = object : MovieRatingListener {
override fun onRatingUpdate(movieName: String, newRating: Float) {
trySend(movieName to newRating)
}
}
// 2
movieRatingService.addRatingListener(listener)
// 3
awaitClose {
movieRatingService.removeRatingListener(listener)
}
}
Dizi’j wuh wke maro uduwe johzp:
Gie tnuaguf i MojuaZubefpXasyozuw. Ykoxebum emCukaymItcoli() dixv xabpak, cei jorz na acey jopi.
Qua arqeq kra rarxafiz bu doseaSepabfXukhomi.
Sumisgp, shugofuy caa pu pindoy caiz pi cettip pi zlalu uhafkf, dai ficohu rro wujwepem gpim pidaaKixuwbGiyqalo.
Jehi, xiu ufiq bma givvjotcYzit viezjoc ne miynivp BaxouXizoqxLodzuzaf ildu u qter.
Qmu berl xroyn lu ke ew la elmaqe SavaTiilRubel ki cosy kolh bdu eqdzimoy YozaiFuqaxabekg. Ekow jka CapeHuavXagiw.xz
akh iploho yomxsWuweacPlVaduguwuat() ezn mojrbZidicizePepucexuiq() xegn gko zupfavuss rama:
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.