MVI is Model — View — Intent, It’s a design pattern that can be used for android application development.
MVI Stands for
- Model — Model is responsible for fetching and providing data from tha Local or Remote source.
- View — View represents a UI Layer, can be Fragment, Activity or anything else. In our particular case,It will be a pure compose function
- Intent — Intent represents the user’s Actions or Events that trigger changes in the Model and the View
MVI in Android Jetpack Compose
Advantages of MVI
- Unidirectional and Cyclic data flow — It’s a design pattern where state flows down and event flows up. With such an approach, we can decouple composable that display a state in the ui from the parts of your app that store and change the state.
- Single Source of Truth — The primary entity in this architecture, from which all other benefits emanate.
- Easiness of Debugging — Since we have only one source of data, it’s easy to debug.
- Easiness of Testing — In most cases, you just need to check a new state after. some event to validate the code, and it’s quite easy to do with the right implementation.