Posts

Showing posts with the label MVVM

MVI / MVVM - Examples

Image
This is the accompanying examples post to  MVI - Overview with Linked Examples . These should be read together starting with that post first. Our Examples We will look at two examples of  MVI  to help explain the concepts. For the purpose of these examples, I will avoid explaining all the layout details. Instead, I will just focus on the organization and how we connect the UI and data. You can always check the full code GitHub Gists to see exactly how everything fits together. Example 1: MVI - Basic Color Selector We have a very simple color selector. This example is too basic to understand the benefits of  MVI , but it does clearly demonstrate how it works. We have our data class and action interface: Basic Color Selector - Data UiState  tracks the state of the UI for our Composable to display the data. data class UiState( val color : Color = noColor , ) UiAction  is used to pass actions from the UI to the ViewModel. interface UiAction { object Cle...

MVI - Overview with Linked Examples

Image
Below, I will focus mainly on MVI , but I will also try to highlight the difference between it and MVVM . If you think you understand the difference but are not 100% sure, I hope this helps bring a little clarity. There will be short code samples later to try and highlight the difference. This blog post is by no means exhaustive, but should serve as a good introduction and overview with relevant links for the details. This blog targets everyone from newer Android Compose programmers to more experienced developers. For the newer programmer, the introduction of this concept should help you organize your code better.  For the more experienced developers, this should serve as a good review and may give additional insights or clarification when explaining these concepts to others. There are also a couple of other posts I have planned that extend on this theme that should be interesting to intermediate to more advanced developers. All the code examples  and related explanations have...