Skip to content

Instantly share code, notes, and snippets.

@rozkminiacz
Created March 12, 2018 09:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozkminiacz/1ce2d2063fc5107b0c099f484ed95a02 to your computer and use it in GitHub Desktop.
Save rozkminiacz/1ce2d2063fc5107b0c099f484ed95a02 to your computer and use it in GitHub Desktop.
class PeopleListPresenter(private val repository: Repository<Person>) : PeopleListContract.Presenter {
var view: PeopleListContract.View? = null
override fun attach(view: PeopleListContract.View) {
this.view = view
loadPeople()
}
private fun loadPeople() {
repository.getAll()
.doOnSubscribe { view?.showLoading() }
.doOnError {
view?.apply {
showError(it)
hideLoading()
}
}
.doOnSuccess {
view?.apply {
addPeople(it)
hideLoading()
}
}
.subscribe()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment