KStore 0.7.1 Help

KStore

logo

Build

Kotlin Alpha Kotlin Maven Central

badge-android badge-ios badge-mac badge-watchos badge-tvos badge-jvm badge-linux badge-windows badge-nodejs badge-browser

A tiny Kotlin multiplatform library that assists in saving and restoring objects to and from disk using kotlinx.coroutines, kotlinx.serialisation and okio. Inspired by RxStore

Features

  • 🔒 Read-write locks; with a mutex FIFO lock

  • 💾 In-memory caching; read once from disk and reuse

  • 📬 Default values; no file? no problem!

  • 🚚 Migration support; moving shop? take your data with you

  • 🚉 Multiplatform!

At a glance

// Take any serializable model @Serializable data class Pet(val name: String, val age: Int) // Create a store val store: KStore<Pet> = storeOf(filePath = "path/to/my_cats.json") // Get, set, update or delete values val mylo: Pet? = store.get() store.set(mylo) store.update { pet: Pet? -> pet?.copy(age = pet.age + 1) } store.delete() // Observe for updates val pets: Flow<Pet?> = store.updates
Last modified: 11 May 2024