Created
March 12, 2018 09:23
-
-
Save rozkminiacz/9d1d7b0db11c432b5223254d84b504b8 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
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