MVI Architecture for Android Tutorial: Getting Started

Learn about the MVI (Model-View-Intent) architecture pattern and prepare to apply it to your next Android app. By Aldo Olivares.

4.3 (24) · 1 Review

Save for later
Share
You are currently viewing page 3 of 3 of this article. Click here to view the first page.

Additional MVI Questions

Q. MVI and MVP look similar. What is the main difference between them?

A. Both patterns rely on similar components such as Presenter, Views and Models. The main difference lies in the implementation of the components and their interactions in an app. For instance, Models in MVI represent a state, and MVP represents data.

Views in MVI tend to have a single render() method that receives the state from the Presenter, which is mapped to the appropriate actions.

Also, MVP tends to be implemented with traditional, imperative programming while MVI is reactive by nature.

Q. Is there an actual Intent layer?

A. It depends. Intents in MVI represent an intention to do something like a database update or a web service call. You won’t always find an Intent package or class in MVI apps.

Q. Is it necessary to use RxJava in MVI?

A. It’s not necessary to use a reactive programming library such as RxJava to create apps with the MVI architecture pattern. However, they will make life much easier when you need to react to UI actions and observe for state changes in your Models.

Q. Has anyone asked you these questions before?

A. No, but someone might, and I want to be ready. : ]

Where to Go From Here?

In this tutorial, you learned the key points of MVI, including:

In summary, MVI is a powerful architecture pattern. It relies on a unidirectional data flow and immutable Models to solve common concerns across Android development such as the state problem and thread safety.

To learn more about RxJava, check out the official ReactiveX website for the documentation and many useful examples.

I also recommend our Advanced Android app Architecture book, which contains three full chapters about MVI as well as other popular architecture patterns such as MVC, MVP, MVVM and VIPER.

Finally, we also have video courses on MVP, MVVM, and MVI. The video courses build a complete app using each of the different patterns.

Feel free to share your feedback or ask any questions in the comments below or in the forums!

  • MVI stands for Model-View-Intent
  • Models in MVI represent a state of an app.
  • A state represents how an app behaves or reacts at any given moment such when loading screen or displaying new data in a list or a network error.
  • Views in MVI can have one or more intent()s that handle user actions and a single render() that renders the state of your app.
  • The Intent represents an intention to perform an action by the user like an API call or a new query in your database. It does not represent the usual android.content.Intent
  • Reducer functions provide steps to merge things into a single component called the accumulator.
  • MVI provides a unidirectional and cyclical data flow.
  • In summary, MVI is a powerful architecture pattern. It relies on a unidirectional data flow and immutable Models to solve common concerns across Android development such as the state problem and thread safety.

    To learn more about RxJava, check out the official ReactiveX website for the documentation and many useful examples.

    I also recommend our Advanced Android app Architecture book, which contains three full chapters about MVI as well as other popular architecture patterns such as MVC, MVP, MVVM and VIPER.

    Finally, we also have video courses on MVP, MVVM, and MVI. The video courses build a complete app using each of the different patterns.

    Feel free to share your feedback or ask any questions in the comments below or in the forums!