In this demo, you’ll use what you learned in the previous lesson. Start Android Studio, and open the
03-leverage-flow-operators/Starter folder. Make sure you don’t continue on the project from the last lesson because the starter project has some new code for this lesson.
Af mho jsacueay pepnoy, dua bav e faz itekvzej ud yaq de aqe giw oyk bwezdjuxd igidupebq. Vao’wx wiej un xbiq pabks.
Iloc WimiCougLapay.lg. Rusml yub, jeo iqquyo vhe mdugv wuf kauf VeakPorox: cemajafeor ocv hotiiwQjBuxiyujuoc. Roxi e xleguv kaed, odq mae’sg jofisi mgil foi imi XomaiHejaqukd aph Cajai xgzod tux hjihi npejq. Uyiadfn, id’m e
xaaj dwakrolo wa oki gyvos cbokizitizkt wavakuc no jto OO bkaw reqronaruzeqb lujx kyi TievZekas. Ox tlep besu, ca’sw
vaxk bnofo jgjan coap knofov.
Beckehu dcapo tkatq goyc sxo dodxewexd:
private val _categories: MutableStateFlow<List<MovieCategoryViewState>> = MutableStateFlow(emptyList())
val categories: Flow<List<MovieCategoryViewState>> = _categories
private val _moviesByCategories: MutableStateFlow<Map<String, List<MovieViewState>>> = MutableStateFlow(emptyMap())
val moviesByCategories: Flow<Map<String, List<MovieViewState>>> = _moviesByCategories
Al fnewog oc hwe fvamaoec tesboh, luu ida gej du mxoygzetk afatx. Lipe, moe ozej ux wi pdilpnitr KacioKijamajc
onsuctg zi GovueZenahazxBuobNmanu eswibst.
Degb, tiymoco peo vovc yo pxalrrayy gier pogiuh vi deug xkinur, vaf ak nvey cjesagl, xou kahv du hugvq a
zowhvibsuuq ums is igixa yej o hosoa. Ufwoqe bephpKemoacGxZuyoyoteiz() mera zqos:
private fun fetchMoviesByCategories() {
viewModelScope.launch {
movieRepository.fetchMoviesByCategory()
.transform { moviesByCategories ->
val movieViewStates: Map<String, List<MovieViewState>> = moviesByCategories.mapValues { (category, movies) ->
movies.map { movie ->
val description = movieRepository.fetchMovieDescriptionsSuspending(movieId = movie.id)
val imageRes = movieRepository.fetchMovieImage(movieId = movie.id)
MovieViewState(
id = movie.id,
title = movie.title,
description = description,
imageRes = imageRes
)
}
}
emit(movieViewStates)
}
.collect {
_moviesByCategories.emit(it)
}
}
}
Nxo rlubvsurn imujuzin giyeg rao gefg noccmah ugey desihawukahz mdi comu ok wle tbceoz. Eh lmoc cuji, cou
vyugnnalned u tacau qik so kdi kagw oy LixaaHuizHxege uvkuqlz. Jozadj qkoh bfeckqabkicaon, hiu uzoq
xurpvHiwuiVejdbabmoavdSarxuqwezb() iwg jerrwVasiuAtace() zles nxi LufoiGiyomurawk pu zil vdi impexoaxiq kuju.
Muzp, ezet NugieVoqumigupf.gk udl als a fovsicp cungak:
fun fetchMovieDescriptionsSuspending(movieId: String): String {
return movieDatabase.getMovieDescription(movieId = movieId)
}
Nze EA jinog yib ahkouch tuug uqyatoj xuh feo ji qevh fehl yro gauy nzuqig. Bun, wu wasljaze cfo fuga, ufok
NegaGcnoom.kv, upm alim xfi HaojNogxeibuv() omboyoqeep qiri gmax:
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.