Setup

VIE ships three artifacts:

Artifact Purpose

org.kodein.arch.vie:vie-mvi

The core: the contract, the ViewModel, middlewares, and EmptyVIE for previews. It has no Compose in it.

org.kodein.arch.vie:vie-compose

VIEView and SignalEffect, to write views in Compose.

org.kodein.arch.vie:vie-test

The test helpers: MockVIE to test a view, runVMTest to test a ViewModel.

A project that writes its views in Compose needs vie-mvi and vie-compose. A SwiftUI app needs vie-mvi only, and copies a few Swift files: see SwiftUI.

VIE 0.2.0 is built with Kotlin 2.4.20, and vie-compose with Compose Multiplatform 1.12.0. Use these versions or newer.

An Android target needs a minSdk of 26 or more, and the JVM artifacts are built for Java 17, so they need a JDK 17 or later. A module that writes views also needs the Kotlin Compose compiler plugin, which Compose projects already apply.

Kotlin Multiplatform

Add vie-mvi to the common code, vie-compose where views are written in Compose, and vie-test to the common tests:

build.gradle.kts
kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("org.kodein.arch.vie:vie-mvi:0.2.0")
            implementation("org.kodein.arch.vie:vie-compose:0.2.0") (1)
        }
        commonTest.dependencies {
            implementation("org.kodein.arch.vie:vie-test:0.2.0") (2)
        }
    }
}
1 Leave it out of a module without a Compose view, such as one that a SwiftUI app shares.
2 A separate artifact, so the test helpers never reach a production source set.

JVM or Android only

A project with a single platform adds the same artifacts to its dependencies:

build.gradle.kts
dependencies {
    implementation("org.kodein.arch.vie:vie-mvi:0.2.0")
    implementation("org.kodein.arch.vie:vie-compose:0.2.0")
    testImplementation("org.kodein.arch.vie:vie-test:0.2.0")
}

Jetpack Compose

vie-compose is built with Compose Multiplatform, and serves an Android project that uses Jetpack Compose as well. On Android, the Compose runtime that it depends on is Google’s androidx.compose.runtime, so your app gets no second Compose.

What comes along

VIE’s own signatures use ViewModel, coroutines and, for vie-compose, Compose types, so these come along as transitive dependencies:

  • androidx.lifecycle:lifecycle-viewmodel, since VIEViewModel extends ViewModel;

  • org.jetbrains.kotlinx:kotlinx-coroutines-core, since models and signals are flows;

  • with vie-compose, org.jetbrains.compose.runtime:runtime, since VIEView and SignalEffect are @Composable;

  • with vie-compose, androidx.lifecycle:lifecycle-viewmodel-compose, since VIEView creates the ViewModel with it.

vie-test also brings org.jetbrains.kotlinx:kotlinx-coroutines-test, which runVMTest is built on.

VIE does not bring Compose Foundation or Material: your views use whichever components you choose.

Supported platforms

The three artifacts target:

  • JVM;

  • Android, API 26 and later;

  • iOS: iosArm64 and iosSimulatorArm64;

  • JS, in the browser;

  • Wasm/JS, in the browser.