MVI in Kotlin Multiplatform — part 1 (1 of 3)
About a year ago I became interested in some new technology: Kotlin Multiplatform. Since then I have been actively experimenting in this area and promoting this technology within our company. One outcome, for example, is our Reaktive library — Reactive extensions for Kotlin Multiplatform.
At Bumble — the parent company operating Badoo and Bumble apps — for Android development, we use the MVI architectural pattern (read more about our architecture Zsolt Kocsi’s article: “MVI beyond state reducers”). Thanks to different projects that I have been working on I have become a big fan of this approach. Of course, I could not miss my opportunity to try MVI in Kotlin Multiplatform. And the occasion was very appropriate: we needed to write samples for the Reaktive library.
All my experiments have left me even more inspired by MVI. In fact, I believe this pattern is best suited to Kotlin Multiplatform so I decided to write this series of three articles on the topic:
- A brief description of the MVI pattern, problem definition and writing the common (shared) module using Kotlin Multiplatform
- Integration of the shared module into iOS and Android applications
- Unit and integration testing
This first article will be of interest to anyone already using or planning to use Kotlin Multiplatform in the near future. To understand the material I cover you are going to need at least some basic knowledge. If you feel that might be lacking in this area, I recommend that you first familiarise yourself with the introduction and the documentation. Prior understanding of the Kotlin/Native memory model is also highly desirable. I especially recommend reading the following Concurrency and Immutability sections of the documentation. This article does not cover the configuration of the project, modules, nor other matters that are not relevant to the topic.
First, let’s recall what MVI is. The acronym MVI stands for Model-View-Intent. There are only two main components in the system: