KStore
2.0.4indexedSave and restore serializable objects to disk with asynchronous IO, in-memory caching, FIFO read–write locks, default values, migration helpers and observable updates via flows.
Save and restore serializable objects to disk with asynchronous IO, in-memory caching, FIFO read–write locks, default values, migration helpers and observable updates via flows.
NOTE: This is fork of KStore. I forked it mainly to support new new Kotlin default hierarchy template It shall most likely be temporary once @xxfast starts mainting the original actively again.
A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialization and kotlinx.io. Inspired by RxStore
KStore is published on Maven Central. Latest version
repositories {
mavenCentral() // should be already there usually
}
# for common
kstore = { module = "tech.arnav:kstore", version.ref = "kstore" }
# for android, iOS, desktop and nodeJs
kstore-file = { module = "tech.arnav:kstore-file", version.ref = "kstore" }
# for jsBrowser and wasmJsBrowser
kstore-storage = { module = "tech.arnav:kstore-storage", version.ref = "kstore" }
Depending on your target platforms, you will need to add platform configurations here
import kotlin.io.path.Path
import kotlinx.serialization.Serializable
// Take any serializable model
@Serializable data class Pet(val name: String, age: )
store: KStore<Pet> = storeOf(file = Path())
mylo: Pet? = store.()
store.(mylo)
store.update { pet: Pet? ->
pet?.copy(age = pet.age + )
}
store.delete()
pets: Flow<Pet?> = store.updates
Documentation here
API Reference here
Copyright 2023 Isuru Rajapakse
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.
Surfaced from shared tags and platforms — no rankings paid for.