-
Notifications
You must be signed in to change notification settings - Fork 0
(MVVM) Model View View Model
Devrath edited this page May 30, 2021
·
10 revisions
- To overcome the drawbacks of MVC, MVP architecture modifications were done to segregate it to a better representation of architecture called Model-View-ViewModel.
- It is one of the very popular ways of structuring the android code.
- MVVM helps you to separate your code into many layers that let you have your own responsibilities.
- Code becomes more
readable,testable,maintainable. - The codebase stands the test of time.
Contents |
|---|
| MVVM block diagram |
| MVP + Repository Pattern block diagram |
| Using the android architecture component in MVP |
- Different people use different variations of the
MVP pattern. - Common and the most popular type of
MVP patternis by using a contract between theviewand thepresenter - The
contractis aninterfacebetween theviewand thepresenter - The
viewcalls a method to initiate an action in thepresenter, the action can be to fetch the data from themodel. - Finally once the
datais retrieved from themodelthepresenternotifies theviewvia thecallback from the contract.
- A
repositoryis used to manage the data fromAPIandloacal database. - We condider
Model=Repository+API+Local Database
- Why not - of course, yes.
- Instead of the
contractthat exists betweenviewandpresenter, We can use aLiveData