Play MVI with Kotlin Coroutines Flow | MVI pattern on Android using Kotlin Coroutines Flow | Dagger Hilt DI | Koin DI | SharedFlow | StateFlow
Liked some of my work? Buy me a coffee (or more likely a beer)
👉 https://github.com/Kotlin-Android-Open-Source/Jetpack-Compose-MVI-Coroutines-Flow
👉 https://github.com/Kotlin-Android-Open-Source/Pagination-MVI-Flow
List view state | Error view state |
---|---|
![]() |
![]() |
Add new user | Search user |
---|---|
![]() |
![]() |
List view state | Error view state |
---|---|
![]() |
![]() |
Add new user | Search user |
---|---|
![]() |
![]() |
This pattern was specified by André Medeiros (Staltz) for a JavaScript framework he has written called cycle.js. From a theoretical (and mathematical) point of view we could describe Model-View-Intent as follows ^1
intent()
: This function takes the input from the user (i.e. UI events, like click events) and translate it to “something” that will be passed as parameter to model()
function.model()
: The model()
function takes the output from intent()
as input to manipulate the Model. The output of this function is a new Model (state changed).model()
function is the only piece of your code that is allowed to create a new Model object.model()
function calls our apps business logic (could be an Interactor, Usecase, Repository … whatever pattern / terminology you use in your app) and delivers a new Model object as result.view()
: This method takes the model returned from model()
function and gives it as input to the view()
function. Then the View simply displays this Model somehow. view()
is basically the same as view.render(model)
.Thanks goes to these wonderful people (emoji key):
Petrus Nguyễn Thái Học 💻 🚧 🤔 🎨 🐛 |
This project follows the all-contributors specification. Contributions of any kind welcome!