Skip to content

Instantly share code, notes, and snippets.

@vvsevolodovich
Created April 13, 2018 07:55
Show Gist options
  • Select an option

  • Save vvsevolodovich/024f06663a434a6ff6adc1f37856d3ea to your computer and use it in GitHub Desktop.

Select an option

Save vvsevolodovich/024f06663a434a6ff6adc1f37856d3ea to your computer and use it in GitHub Desktop.
Objects under the hood
// 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