# MVVM vs MVI

## MVVM

On Android, MVVM can be drawn as the following:

<img src="/files/dxbKSq3p0eFPdpYJBnox" alt="MVVM on Android" class="gitbook-drawing">

The ViewModel keeps a persistent UiState in a StateFlow which is observed by the Screen to update its UI.

The Fragment (or Screen), on every trigger of an UI Event, calls directly a function to trigger some code that will update the UiState.

This is all good, but the number of functions to call from the Fragment to the ViewModel can become big and makes the class feel messy, so let's see what MVI adds to the table.

## MVI

What we take from MVI on Android is just transforming all those UI Event functions into types and passing then to one only function, usually called **`handleEvent()`** :

<img src="/files/Mg0YsXV209kkz4iKAiqQ" alt="MVI on Android" class="gitbook-drawing">


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.galex.dev/yamvil/mvvm-vs-mvi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
