Created
April 13, 2018 07:55
-
-
Save vvsevolodovich/024f06663a434a6ff6adc1f37856d3ea to your computer and use it in GitHub Desktop.
Objects under the hood
This file contains hidden or 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
| // new SingleFlatMap() | |
| val flatMap = apiClient.login(auth) | |
| .flatMap { apiClient.getRepositories(it.repos_url, auth) } | |
| // new SingleMap | |
| val map = flatMap | |
| .map { list -> list.map { it.full_name } } | |
| // new SingleSubscribeOn | |
| val subscribeOn = map | |
| .subscribeOn(Schedulers.io()) | |
| // new SingleObserveOn | |
| val observeOn = subscribeOn | |
| .observeOn(AndroidSchedulers.mainThread()) | |
| // new SingleDoFinally | |
| val doFinally = observeOn | |
| .doFinally { showProgress(false) } | |
| // new ConsumerSingleObserver | |
| val subscribe = doFinally | |
| .subscribe( | |
| { list -> showRepositories(this@LoginActivity, list) }, | |
| { error -> Log.e("TAG", "Failed to show repos", error) } | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment