MVI on Android
In this course, you will use RxJava to build an app using the Model-View-Intent architecture, learning about components like intents, results, and state. By Joe Howard.
This is part of the Android Architecture learning path. View path.
Who is this for?
This course is for intermediate Android developers who have previously been exposed to architecture considerations on Android. They have potentially used patterns like MVP and MVVM but are looking to use MVI for the first time or have used MVI but are looking for a deeper understanding of the pattern.
Students will learn:
- The concepts and structure of the MVI pattern
- MVI actions and intents
- How to build an app using MVI
- How to test an MVI app
- Where MVI fits in within a more complicated app architecture
- How to define and process results
- How to define a view state and render it to the screen
Part 1: From Intention to Action
Let's introduce the Model-View-Intent architecture, identify the sample project we'll be working with, and see an outline of the course.
Learn about the origins and theory of MVI, and get introduced to the MVI event cycle, which we'll use throughout the course.
The Starter Project
Take a tour through the starter project code, and learn how it differs from the code in our other architecture courses.
See a summary of prereqs for the course, which include intermediate knowledge of Android, experience with sealed classes, and a basic understanding of RxJava.
MVI Base Interfaces
Create the base interfaces that will be used for the MVI component types, and define behavior for the View and ViewModel classes within MVI.
Identify the MVI intents for each screen of the app, and create Kotlin sealed classes to represent the intents
Practice defining an intent for the Add Creature screen on your own, through a hands-on challenge. Then see a solution.
Identify the MVI actions for each screen of the app, and create Kotlin sealed classes to represent the actions.
Practice defining an action for the Add Creature screen on your own, through a hands-on challenge. Then see a solution.
Let's review where you are within the overall MVI cycle, and discuss what's next: building out the remainder of the cycle.
Part 2: Results, State, and the View
Let's review what you'll be doing in this part of the course, building out the second half of the MVI cycle and finishing the app.
Define results for the All Creatures screen, then use an Rx ObservableTransformer to process actions into results.
Define results for the Add Creature screen, then use an Rx ObservableTransformer to process actions into results.
Practice defining results and a processor for the Add Creature screen on your own, through a hands-on challenge. Then see a solution.
Defining View State
Learn how to think about the state of your screen's view, and define a view state for both screens of the app.
Reducing to State
See how reducers are used to combine previous view state with results to create a new view state, and define view state classes for each screen.
Practice defining a reducer for the Add Creature screen on your own, through a hands-on challenge. Then see a solution.
Complete the remainder of code needed for the app ViewModels, by turning intents into actions, processing to results, and reducing results to new view state.
Rendering the View 1
Add a ViewModel property for the All Creatures screen, bind to the ViewModel, and render view state to the screen.
Rendering the View 2
Add a ViewModel property for the Add Creature screen, bind to the ViewModel, and render view state to the screen.
Learn about how to set up tests for an MVI ViewModel class, using JUnit and Mockito. Then define tests for the loading intent on the All Creatures screen.
Let's review what you learned in this course, discuss the benefits of the MVI architecture, and see where to go from here.