Skip to content
プロジェクト

概要

Kotlin Multiplatform向けの拡張可能なMVIフレームワーク。ログ記録や時間をさかのぼるデバッグなど、強力なデバッグツールを備えています。

開発ツール

この数値の測り方

できること

  • Multiplatform: Android, JVM, iOS, watchOS, tvOS, macOS, linuxX64, JavaScript, Wasm (since 4.0.0-alpha02)
  • Does not depend on any reactive library or coroutines
  • Extensions for Reaktive library
  • Extensions for Coroutines

計測したスター増加

24時間
0
7日間
+1
15日間
+1
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

Maven Central License kotlinlang|MVIKotlin

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

[!NOTE] This project is not stale; it is feature complete. I am actively keeping it up to date with necessary maintenance and updates.

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.

MVI

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.

MVIKotlin

Responsibilities and architecture

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

  • To provide a single source of truth for State. The scope is not defined, it can be a whole app, a screen, a feature, or a part of a feature.

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

  • To provide an abstraction for UI with efficient updates (diffing).
  • To provide lifecycle aware connections (bindings) between inputs and outputs.

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:

  • MVIKotlin can be introduced incrementally (e.g. you can start using it in a small feature and then expand gradually);
  • You can use/experiment with different architectures, approaches and/or libraries for navigation, UI, modularization, etc;
  • Use whatever reactive framework you like or don't use it at all.

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:

  • mvikotlin - core interfaces and functionality (multiplatform)
  • mvikotlin-main - the main module with the default Store implementation (multiplatform)
  • mvikotlin-logging - logging functionality (multiplatform)
  • mvikotlin-timetravel - time travel feature (multiplatform)
  • mvikotlin-extensions-reaktive - extensions set for Reaktive library (multiplatform)
  • mvikotlin-extensions-coroutines - extensions set for coroutines (multiplatform)
  • keepers - provides StateKeeper and InstanceKeeper API for state preservation and objects retaining (deprecated, see the documentation)
  • rx - a tiny module with abstractions over rx and coroutines (multiplatform)

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

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

Features

  • Multiplatform: Android, JVM, iOS, watchOS, tvOS, macOS, linuxX64, JavaScript, Wasm (since 4.0.0-alpha02)
  • Does not depend on any reactive library or coroutines
  • Extensions for Reaktive library
  • Extensions for Coroutines
  • Lifecycle-aware connections (bindings) between inputs and outputs
  • Logging functionality with customizable logger and formatter
  • Time travel feature:
    • Multiplatform for all supported targets
    • Export/import events for Android
    • IntelliJ IDEA and Android Studio plugin for Android apps
    • Desktop client application for Android, Java and native Apple (iOS, watchOS, tvOS, macOS) apps
    • Chrome DevTools extension for Web browser apps

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 sample 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

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

"Used by" list

Checkout a voluntary list of projects/companies using MVIKotlin: https://github.com/arkivanov/MVIKotlin/discussions/90. Feel free to add your project!

Author

Twitter: @arkann1985

If you like this project you can always Buy Me A Coffee ;-)

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

Powered by

JetBrains logo.

関連プロジェクトを探す

読み込み中…