Forked from douglasiacovelli/keep-original-value-rxjava-2.kt
Created
April 25, 2020 16:36
-
-
Save Heroes84/aa4a870d91029dc790fe9b626f39d96e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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