Model View Intent: a new Android Architecture Pattern

mvi
Software Architecture Tips

Model View Intent: a new Android Architecture Pattern

Android community has adopted patterns like MVP, MVC, MVVM, etc. And recently, we all started hearing another pattern called MVI or Model View Intent, so today I would like to discuss it in this post. 

Model-View-Intent ( MVI ) 

MVI stands for Model-View-Intent. MVI is one of the newest architecture patterns for Android, inspired by the unidirectional and cyclical nature of the Cycle.js framework.

  • Model: is a term which is common to various patterns like MVC: Model View Controller, MVP: Model View Presenter, MVVM: Model View ViewModel. Model represents a state. This includes interactions with business logic. 
  • Intent: the intent simply describes an intention, or action, or command generated by the user as he or she is interacting with the app. An intent represents the interaction with the view by the user. The intent delivers changes that need to be processed by the Model. 
  • View: The view, actual the UI, observes and depicts the model’s state. The view forwards each interaction as intent.

 

Model-View-Intent relies heavily on reactive and functional programming. 

MVI is a derivation of the original MVC architectural pattern. Instead of working with a proactive controller MVI works with the reactive component called intent:

“Intent is a component whose sole responsibility is to translate user input events into model-friendly events. It should interpret what the user is trying to do in terms of model updates, and export these ‘user intentions’ as events. It translates ‘View idioms’ to ‘Model idioms.’ Intent itself doesn’t change anything else, as any other typical Reactive component doesn’t, by definition.” – Andre Medeiros

 

Let’s look more deeply on the MVI mechanic:

In MVI, the view is exposing an observable for the intent to capture all the user interactions from the view and passing the data through an observable to the intent. The intent is preparing the data received for the model, and these data are passed to the model via an observable again. Model saves this data and updates the view exposing an observable to the view.

 

Differences between MVI & MVP

Model-View-Presenter (MVP) is a software architectural pattern which is based on Model-View-Controller, exactly as Model-View-Intent (MVI). These are the main differences MVP pattern has:  

  • MVP is used to implement user interfaces while keeping separation between the model and the view. 
  • The interactions are controlled by the presenter which acts as an mediator between model and View. 
  • One to one mapping between View and Presenter, with the possibility to use multiple Presenters for more complex Views.

 

If you have any questions, let us know! Our Android team has implemented this pattern in their projects and would be happy to help! 

Leave your thought here

Your email address will not be published. Required fields are marked *

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
  • Attributes
  • Custom attributes
  • Custom fields
Click outside to hide the comparison bar
Compare
Compare ×
Let's Compare! Continue shopping