You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am having some trouble wrapping my head around how to handle multiple network calls (probably because I am new to kotlin and android development). Given two network calls, A and B, which are not dependent on each other, how would I go about "merging" the data from both network calls into a custom model.
It is similar to the example provided in the Google article regarding the Domain Layer
I am thinking a nested .onSuccess lambda might work but not sure if it would be best practice. I was looking at the Model Mapper documentation but I am a bit confused on how to use it in this case. Would a Flow approach be better even though this would be a one-shot network call?
classGetMovieDetailsWithCast @Inject constructor(
privatevalrepository:NetworkTMDBRepository,
) {
suspendoperatorfuninvoke(id:Int) {
val movie = repository.fetchMovieDetails(id) // ApiResponse<NetworkMovieDetails>val credits = repository.fetchMovieCredits(id) // ApiResponse<NetworkMovieCredits>/* do some processing here */MovieDetailsWithCredits(movie = movie, credits = credits) // where movie and credits are of NetworkMovieDetails and NetworkMovieCredits
}
}
Thanks in advance.
The text was updated successfully, but these errors were encountered:
Hello,
I am having some trouble wrapping my head around how to handle multiple network calls (probably because I am new to kotlin and android development). Given two network calls, A and B, which are not dependent on each other, how would I go about "merging" the data from both network calls into a custom model.
It is similar to the example provided in the Google article regarding the Domain Layer
I am thinking a nested
.onSuccess
lambda might work but not sure if it would be best practice. I was looking at the Model Mapper documentation but I am a bit confused on how to use it in this case. Would aFlow
approach be better even though this would be a one-shot network call?Thanks in advance.
The text was updated successfully, but these errors were encountered: