val show = showsApi.getShowByName("Friends") val characters = showsApi.getCharacters(show.id) withContext(Dispatchers.Main){ // do something with characters on UI } }
cont) Continuation CoroutineScope.launch(Dispatchers.IO){ val show = showsApi.getShowByName("Friends") val characters = showsApi.getCharacters(show.id) withContext(Dispatchers.Main){ // do something with characters on UI } }
sm.item = "Friends" sm.label = 1 showsApi.getShowsByName(“Friends”, cont) CoroutineScope.launch(Dispatchers.IO){ val show = showsApi.getShowByName("Friends") val characters = showsApi.getCharacters(show.id) withContext(Dispatchers.Main){ // do something with characters on UI } }
showsApi.getCharacters(show.id, cont) sm.item = "Friends" sm.label = 1 showsApi.getShowsByName(“Friends”, cont) Continuation CoroutineScope.launch(Dispatchers.IO){ val show = showsApi.getShowByName("Friends") val characters = showsApi.getCharacters(show.id) withContext(Dispatchers.Main){ // do something with characters on UI } }
class Result<out T> { data class Success<out T>(val data: T) : Result<T>() data class Error(val exception: Exception) : Result<Nothing>() } • Gotta catch them all onError onErrorReturn onErrorResumeNext doOnError onErrorComplete onErrorReturnItem
getNowPlayingMovies(), BiFunction<Movies, Movies, Movies> { popularMovies, topRatedMovies, -> // Filter from popular and top rated movies }.subscribeOn(Scheduler.io())
getNowPlayingMovies(), BiFunction<Movies, Movies, Movies> { popularMovies, topRatedMovies, -> // Filter from popular and top rated movies }.subscribeOn(Scheduler.io())
getNowPlayingMovies(), BiFunction<Movies, Movies, Movies> { popularMovies, topRatedMovies, -> // Filter from popular and top rated movies }.subscribeOn(Scheduler.io())
getNowPlayingMovies(), BiFunction<Movies, Movies, Movies> { popularMovies, topRatedMovies, -> // Filter from popular and top rated movies }.subscribeOn(Scheduler.io())
(T1, T2) -> R) = coroutineScope { // wait for two calls to complete async { zipper(source1.await(), source2.await()) } } Zip Calls in • Let’s cook zip +
(T1, T2) -> R) = coroutineScope { // wait for two calls to complete async { zipper(source1.await(), source2.await()) } } Zip Calls in • Let’s cook zip + Zip Deferred 1 Deferred 2 Zipper Result
(T1, T2) -> R) = coroutineScope { // wait for two calls to complete async { zipper(source1.await(), source2.await()) } } Zip Calls in • Let’s cook zip +
= async{ getPopularMovies() } val topRatedMovies = async{ getTopRatedMovies() } zip(popularMovies, topRatedMovies) { popularResults, topRatedResults -> // Filter from popular and top rated movies return filteredResults }.await() } Zip Calls in
= async{ getPopularMovies() } val topRatedMovies = async{ getTopRatedMovies() } zip(popularMovies, topRatedMovies) { popularResults, topRatedResults -> // Filter from popular and top rated movies return filteredResults }.await() } Zip Calls in
= async{ getPopularMovies() } val topRatedMovies = async{ getTopRatedMovies() } zip(popularMovies, topRatedMovies) { popularResults, topRatedResults -> // Filter from popular and top rated movies return filteredResults }.await() } Zip Calls in