Setup
VIE ships three artifacts:
| Artifact | Purpose |
|---|---|
|
The core: the contract, the ViewModel, middlewares, and |
|
|
|
The test helpers: |
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:
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:
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, sinceVIEViewModelextendsViewModel; -
org.jetbrains.kotlinx:kotlinx-coroutines-core, since models and signals are flows; -
with
vie-compose,org.jetbrains.compose.runtime:runtime, sinceVIEViewandSignalEffectare@Composable; -
with
vie-compose,androidx.lifecycle:lifecycle-viewmodel-compose, sinceVIEViewcreates 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.