
Tracks editable and applied values, exposes an uncommitted-change indicator, supports commit/revert operations, and grouping to commit or revert only dirty child states.
Reversible state holders for Kotlin Multiplatform.
ReversibleState tracks an editable value alongside an applied value, exposes whether there are uncommitted changes, and provides commit/revert operations for pushing or discarding edits.
dependencies {
implementation("io.github.w2sv:reversible-state:<version>")
}For Kotlin Multiplatform projects:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.w2sv:reversible-state:<version>")
}
}
}val appliedState = MutableStateFlow("saved")
val state = ReversibleStateFlow(
scope = scope,
appliedState = appliedState,
commitState = { appliedState.value = it }
)
state.value = "draft"
check(state.isDirty.value)
suspend fun save() {
state.commit()
}
state.revert()Use ReversibleStateComposition to group several reversible states and commit or revert only the dirty children.
Apache License 2.0. See LICENSE.
Reversible state holders for Kotlin Multiplatform.
ReversibleState tracks an editable value alongside an applied value, exposes whether there are uncommitted changes, and provides commit/revert operations for pushing or discarding edits.
dependencies {
implementation("io.github.w2sv:reversible-state:<version>")
}For Kotlin Multiplatform projects:
kotlin {
sourceSets {
commonMain.dependencies {
implementation("io.github.w2sv:reversible-state:<version>")
}
}
}val appliedState = MutableStateFlow("saved")
val state = ReversibleStateFlow(
scope = scope,
appliedState = appliedState,
commitState = { appliedState.value = it }
)
state.value = "draft"
check(state.isDirty.value)
suspend fun save() {
state.commit()
}
state.revert()Use ReversibleStateComposition to group several reversible states and commit or revert only the dirty children.
Apache License 2.0. See LICENSE.