https://github.com/prosumma/kostore
Kotlin type-safe hierarchical storage
https://github.com/prosumma/kostore
Last synced: about 1 year ago
JSON representation
Kotlin type-safe hierarchical storage
- Host: GitHub
- URL: https://github.com/prosumma/kostore
- Owner: Prosumma
- Created: 2022-01-23T14:17:06.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-24T03:05:09.000Z (over 4 years ago)
- Last Synced: 2025-01-29T11:46:16.419Z (over 1 year ago)
- Language: Kotlin
- Size: 71.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# KoStore
KoStore allows the simple creation of a type-safe, hierarchical data store that is not "stringly typed". Any serializable data type may be stored.
```kotlin
class ConfigDomain(parent: AppDomain): ChildDomain(NAME, parent) {
companion object {
const val NAME = "config"
}
val apiUrl: String by stored { "https://api.myserver.com" }
val maxRetries: Int? by stored()
}
// Add ConfigDomain as a child of AppDomain
val AppDomain.config: ConfigDomain by child(ConfigDomain.NAME, ::ConfigDomain)
fun main() {
val appDomain = AppDomain(SharedPreferencesContainer())
appDomain.config.maxRetries = 5
print(appDomain.config.apiUrl)
}
```