arch-toolkit

📦 Arch Toolkit · Storage DataStore

Maven Central CI Status Android Apple JVM JS WASM LICENSE COVERAGE

A persistent [StorageProvider] implementation backed by AndroidX DataStore Preferences. Part of the Arch Toolkit.


✨ Features


🚀 Quick Start

Add as dependency:

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

📖 Usage Examples

Primitives

val provider = DataStoreProvider(store)

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

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

Enum

enum class Theme { Light, Dark }

val theme = provider.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 = provider.model(
    key = "user",
    fromJson = { Json.decodeFromString<User>(it) },
    toJson = { Json.encodeToString(it) }
)

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

🛠️ Providers Overview


🧩 Targets

Target Status
Android/JVM ✅ Persistent (DataStore)
iOS/macOS ✅ Persistent (KMP DataStore)
JS/WASM ⚠️ Stub (noop)

📦 Part of Arch Toolkit

The Storage DataStore module is part of the Arch Toolkit storage ecosystem:


📄 License

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