Skip to content

Instantly share code, notes, and snippets.

@surajsau
Created July 18, 2019 12:28
Show Gist options
  • Save surajsau/b446475edb1c01752f2cbb183cf73821 to your computer and use it in GitHub Desktop.
Save surajsau/b446475edb1c01752f2cbb183cf73821 to your computer and use it in GitHub Desktop.
MVP to MVVM: Tight Coupling
class MainActivity : AppCompatActivity(), MainView {
val presenter: MainPresenter by currentScope.inject()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
..
}
override fun doSomething() {..}
}
/*
Traditional implementation of MVP, with instance of View
present in the Presenter. This forces Presenter to be limited
only on this UI Controller
*/
class MainPresenter(val service: GithubService, val view: MainView) {
private fun onSearchResultReceived(apiResponse: ApiResponse?) {
view?.doSomething(..)
..
}
..
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment