Skip to content

Instantly share code, notes, and snippets.

@gilgoldzweig
Last active February 12, 2019 17:24
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 gilgoldzweig/a4961d19ed6ef052db1caa35b593c80f to your computer and use it in GitHub Desktop.
Save gilgoldzweig/a4961d19ed6ef052db1caa35b593c80f to your computer and use it in GitHub Desktop.
open class ExamplePresenter : ExampleContract.Presenter {
var view: ExampleContract.View? = null
override fun attach(view: ExampleContract.View) {
this.view = view
}
override fun fetchProfileName() {
val name: String
try {
name = fetchProfileNameFromRepository()
} catch (io: IOException) {
view?.onProfileNameRequestFailed(io)
return
}
view?.onProfileNameReceived(name)
}
open fun fetchProfileNameFromRepository(): String {
//Long operation that calls the repository and return the name or throws an exception
}
override fun detach() {
view = null
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment