ReactiveState

Kotlin Multiplatform ViewModels and reactive state management based on StateFlow.
See the ReactiveState documentation for more details.
Examples
Map/transform a StateFlow:
val number = MutableStateFlow(0)
val doubledNumber: StateFlow<Int> = derived { 2 * get(number) }
Collect two StateFlows (just collect without transforming):
val base = MutableStateFlow(0)
val extra = MutableStateFlow(0)
autoRun {
if (get(base) + get(extra) > 10) {
alert("You're flying too high")
}
}
Multiplatform ViewModels with automatic error handling and loading indicator tracking:
class ExampleViewModel(scope: CoroutineScope, val repository: ExampleRepository) : ReactiveViewModel(scope) {
val inputFieldValue = MutableStateFlow("default")
fun submit() {
launch {
repository.submit(inputFieldValue.value)
}
}
}
Intercept MutableStateFlow:
public val state: MutableStateFlow<String> = MutableStateFlow("value").afterUpdate {
}
Convert StateFlow to MutableStateFlow:
val readOnly: StateFlow<Int> = getSomeStateFlow()
val mutable: MutableStateFlow<Int> = readOnly.toMutable { value: Int ->
}
See the ReactiveState documentation for more details.
Supported platforms
- Android
- JVM
- All native (including iOS)
- JS
- WASM
Installation
Add the package to your build.gradle.kts's dependencies {}:
dependencies {
api(platform("com.ensody.reactivestate:reactivestate-bom:VERSION"))
api("com.ensody.reactivestate:reactivestate-compose")
api("com.ensody.reactivestate:reactivestate-android")
api("com.ensody.reactivestate:reactivestate-core")
api()
api()
}
Also, make sure you've integrated the Maven Central repo, e.g. in your root build.gradle.kts:
subprojects {
repositories {
mavenCentral()
}
}
License
Copyright 2026 Ensody GmbH, Waldemar Kornewald
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.