Created
July 18, 2019 12:28
-
-
Save surajsau/b446475edb1c01752f2cbb183cf73821 to your computer and use it in GitHub Desktop.
MVP to MVVM: Tight Coupling
This file contains hidden or 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 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