
Lightweight, type-safe state-management architecture with expressive DSL, lifecycle-aware state retention, granular state observation, effect/signal handling, and cancellable asynchronous jobs for reactive UI development.
Anchor is a lightweight, type-safe state management architecture for Kotlin Multiplatform projects, specifically designed for Jetpack Compose. It leverages Kotlin's modern features like Context Receivers and SAM conversions to provide a clean, expressive, and powerful DSL.
Visit kioba.github.io/anchor/ for the full documentation!
Add the dependencies to your build.gradle.kts:
dependencies {
implementation("dev.kioba.anchor:anchor:0.1.1")
implementation("dev.kioba.anchor:anchor-compose:0.1.0")
testImplementation("dev.kioba.anchor:anchor-test:0.1.0")
}Defining a simple Counter component with Anchor:
data class CounterState(val count: Int = 0) : ViewState
typealias CounterAnchor = Anchor<EmptyEffect, CounterState, Nothing>
fun RememberAnchorScope.counterAnchor(): CounterAnchor =
create(initialState = ::CounterState, effectScope = { EmptyEffect })fun CounterAnchor.increment() {
reduce { copy(count = count + 1) }
}
fun CounterAnchor.decrement() {
reduce { copy(count = count - 1) }
}@Composable
fun CounterUi() {
RememberAnchor(scope = { counterAnchor() }) {
val count = collectState { it.count }
Column {
Text("Count: $count")
Row {
Button(onClick = anchor(CounterAnchor::decrement)) { Text("-") }
Button(onClick = anchor(CounterAnchor::increment)) { Text("+") }
}
}
}
}For comprehensive details, check out our documentation:
Contributions are welcome! If you'd like to help improve Anchor, feel free to:
When contributing, please ensure your code follows the existing style and includes appropriate tests.
Copyright 2026 Karoly Somodi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Anchor is a lightweight, type-safe state management architecture for Kotlin Multiplatform projects, specifically designed for Jetpack Compose. It leverages Kotlin's modern features like Context Receivers and SAM conversions to provide a clean, expressive, and powerful DSL.
Visit kioba.github.io/anchor/ for the full documentation!
Add the dependencies to your build.gradle.kts:
dependencies {
implementation("dev.kioba.anchor:anchor:0.1.1")
implementation("dev.kioba.anchor:anchor-compose:0.1.0")
testImplementation("dev.kioba.anchor:anchor-test:0.1.0")
}Defining a simple Counter component with Anchor:
data class CounterState(val count: Int = 0) : ViewState
typealias CounterAnchor = Anchor<EmptyEffect, CounterState, Nothing>
fun RememberAnchorScope.counterAnchor(): CounterAnchor =
create(initialState = ::CounterState, effectScope = { EmptyEffect })fun CounterAnchor.increment() {
reduce { copy(count = count + 1) }
}
fun CounterAnchor.decrement() {
reduce { copy(count = count - 1) }
}@Composable
fun CounterUi() {
RememberAnchor(scope = { counterAnchor() }) {
val count = collectState { it.count }
Column {
Text("Count: $count")
Row {
Button(onClick = anchor(CounterAnchor::decrement)) { Text("-") }
Button(onClick = anchor(CounterAnchor::increment)) { Text("+") }
}
}
}
}For comprehensive details, check out our documentation:
Contributions are welcome! If you'd like to help improve Anchor, feel free to:
When contributing, please ensure your code follows the existing style and includes appropriate tests.
Copyright 2026 Karoly Somodi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.