Home

Awesome

<img src="https://raw.githubusercontent.com/arkivanov/MVIKotlin/master/docs/media/logo/landscape/png/mvikotlin_coloured.png" height="64">

Maven Central License kotlinlang|MVIKotlin

Should you have any questions or ideas - there is Discussions section. Also welcome to the Kotlin Slack channel - #mvikotlin!

⚡⚡⚡ Where are all the stars, issues, discussions, pull requests, etc?

Having spent 5 years working on a variety of projects for Badoo/Bumble, I’m now off to another adventure. As part of that transition I was asked to transfer this repository to Badoo GitHub account.

Now I continue my work on this project as a copy.

There should be no breaking changes related to this transfer. Most of the external links should not be broken. The repository link is also the same: arkivanov/MVIKotlin. Please file an issue in this repository, if you think something is broken or does not work properly.

Here is what is mostly affected by the transfer:

I will continue doing all my best for this project and for the community! Business as usual!

Additional resources:

Overview

What is MVI

MVI stands for Model-View-Intent. It is an architectural pattern that utilizes unidirectional data flow. The data circulates between Model and View only in one direction - from Model to View and from View to Model.

<img src="docs/media/mvi.jpg" alt="MVI" width="300"/>

What is MVIKotlin

MVIKotlin is a Kotlin Multiplatform framework that provides a way of (not only) writing shared code using MVI pattern. It also includes powerful debug tools like logging and time travel. The main functionality of the framework does not depend on any reactive nor coroutines library. Extensions for Reaktive and for Coroutines libraries are provided as separate modules.

<img src="docs/media/mvikotlin.jpg" alt="MVIKotlin" width="600"/>

Responsibilities and architecture

MVIKotlin does not bring or enforce any particular architecture. There is one primary responsibility of the library:

There are also two optional responsibilities, which the library can take care of for you:

Everything else is out of scope of the library, there are no definitions for "screens", "features", "modules", etc. Also, no particular reactive framework is enforced/exposed. This gives a lot of flexibility:

If you are using declarative UI frameworks (like Jetpack Compose, Multiplatform Compose by JetBrains, SwiftUI, React, etc.), then consider using Decompose for architecture. MVIKotlin plays nicely with Decompose.

Also one of the architecture approaches can be found in the samples.

Setup

Recommended minimum Gradle version is 5.3. Please read first the documentation about metadata publishing mode.

There are a number of modules published to Maven Central:

Add required modules to your module`s build.gradle file:

implementation "com.arkivanov.mvikotlin:<module-name>:<version>"

Features

Documentation

https://arkivanov.github.io/MVIKotlin

Sample project

The sample project is a todo list with details view. There are two implementations of the same sample, one using Reaktive library and another one using coroutines. Each variant has Android, iOS and Web browser apps. This samples also demonstrates one of the possible architectures for a multiplatform project - each screen is represented by a controller class, platform applications integrate controllers and navigate between them.

Structure

Sample TodoApp in JetBrains/compose-jb

There is another sample project available in forked repository of JetBrains/compose-jb - TodoApp. It uses MVIKotlin for business logic and Decompose for navigation.

Author

Twitter: @arkann1985

If you like this project you can always <a href="https://www.buymeacoffee.com/arkivanov" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" height=32></a> ;-)

Watch video (time travel, logs, debug, etc.)

Debugging Android application with MVIKotlin

Debugging Android application with MVIKotlin

Debugging iOS application with MVIKotlin

Debugging iOS application with MVIKotlin

Debugging Android application with IntelliJ IDEA time travel plugin

Debugging Android application with IntelliJ IDEA time travel plugin

Debugging iOS application using MVIKotlin time travel client app

Debugging iOS application using MVIKotlin time travel client app