arch-toolkit

📦 Arch Toolkit · Storage Core

Maven Central
CI Status
Android
Apple
JVM JS
WASM
LICENSE
COVERAGE

A multiplatform reactive storage abstraction for key–value data. Part of the Arch Toolkit.


✨ Features

* Web targets fallback to noop stubs.


🚀 Quick Start

Add the core module as dependency:

implementation("io.github.matheus-corregiari:storage-core:<version>")

Then choose one of the available providers:


📖 Usage Examples

Basic

val storage: StorageProvider = DataStoreProvider(store)

val isLoggedIn = storage.boolean("is_logged_in")
val userName = storage.string("user_name")

isLoggedIn.set(true)
println("User: ${userName.instant()}")

Enum

enum class Theme { Light, Dark }

val theme = storage.enum("theme", Theme.entries, Theme.Light)

theme.set(Theme.Dark)
println("Theme is ${theme.instant()}")

JSON Model

@kotlinx.serialization.Serializable
data class User(val id: String, val name: String)

val user = storage.model<User>("user")

user.set(User("42", "Alice"))
println("User: ${user.instant()}")

Compose Integration

@Composable
fun UserNameInput(userName: KeyValue<String?>) {
    val state = userName.state()
    TextField(
        value = state.value.orEmpty(),
        onValueChange = { state.value = it }
    )
}

Delegated Property

var counter by storage.int("counter").required { 0 }.delegate()

counter += 1
println("Counter is $counter")

🛠️ Providers


⚙️ JSON Configuration

By default, models use the built-in Json configuration:

ignoreUnknownKeys = true
encodeDefaults = true
prettyPrint = true

Override globally if needed:

StorageProvider.json(Json {
    ignoreUnknownKeys = false
})

🧩 Targets Overview

Target Provider(s) Status
Android/JVM DataStore
iOS/macOS DataStore (KMP)
JS/WASM Noop (stub only) ⚠️
Any Memory

🧪 Testing

For unit tests or non-persistent use cases, use the in-memory provider:

val memory = MemoryStoreProvider(mutableMapOf())
val flag = memory.boolean("feature_enabled")

flag.set(true)
println(flag.instant()) // true


📦 Part of Arch Toolkit

The Storage Core is one of the building blocks of Arch Toolkit, designed to provide:


📄 License

This module is released under the Apache 2.0 License. See LICENSE for details.


```