2

I'm trying to chain two reactive calls which return Completable using retrofit on android:

val userRequest = ...
val languageRequest = ...

return userService.updateUser(userRequest)
    .andThen { userService.updateMessagingUserLanguages(user.id, languageRequest) }
    .doOnComplete { userRepository.updateUser(user) }

which are defined as follow:

@PUT("$BASE_USER_URL")
fun updateUser(@Body user: UserRequest): Completable

@PUT("$BASE_URL/{userId}/languages")
fun updateMessagingUserLanguages(@Path("userId") userId: Long, @Body request: MessagingLanguageDTO): Completable

The first Completable succeed and returns a response with a 200 status. However, the second call is never triggered (it never appears in my log and does not pass my breakpoint).

What am I missing here?

Benjamin
  • 7,055
  • 6
  • 40
  • 60

1 Answers1

3

Try:

andThen(userService.updateMessagingUserLanguages(user.id, languageRequest))

IOW, replace the lambda expression as a parameter with the actual Completable that you want to add to the chain.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491