Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Heroes84/aa4a870d91029dc790fe9b626f39d96e to your computer and use it in GitHub Desktop.
Save Heroes84/aa4a870d91029dc790fe9b626f39d96e to your computer and use it in GitHub Desktop.
Observable.just("Will")
.observeOn(Schedulers.io())
.flatMap({ name ->
updateUserName.execute(name) //returns another Observable<ApiResult> after calling the API
}, {
//this is executed after resolving the last observable emitted, so the result is ready.
name: String, apiResult: ApiResult -> Pair(name, apiResult)
})
.subscribe({ result ->
result.first //name
result.second //apiResult
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment