kotlingang / kds Goto Github PK
View Code? Open in Web Editor NEWKotlin Data Storage is a multiplatform coroutine-based kotlin library for storing Serializables with kotlinx.serialization and delegates
Kotlin Data Storage is a multiplatform coroutine-based kotlin library for storing Serializables with kotlinx.serialization and delegates
Now there is no way to use PrimitiveStorage
safely
Another one architecture idea is to make something like properties
as root entity. Files should be encapsulated under this and extends properties. I should create new abstract entity responsible for writing content synchronous or asynchronous.
class MainActivity : Activity() {
private object MBundle : KBundleDataStorage() {
var selectedTab by integer { R.id.home }
var selectedPicture by nullableString() // URI
}
override fun onCreate(bundle: Bundle) = MBundle.fillBundle(bundle) {
setSelectedTab(MainScreen.selectedTab)
setPicture(selectedPicture)
}
override fun onSaveInstanceState() = MBundle.bundle
private fun setSelectedTab(id: Int) = TODO()
private fun setPicture(pictureUri: String) = TODO()
}
This potentially may reduce pain from state saving in android. May be a replacement of libraries kind of a bundle delegates since the api used there is common with preferences.
This annotation required to mark some APIs as unstable and give users the ability to choose which part of API they will use
awaitLoading()
Required at start of your program to await file reading
Why just not to read file blocking when class instance created?
The files with data are usually small, but for example if your android app runs on low version and you are using object
to initialize storage, you can get freeze at lazy initialization.
Firstly that let you know where your app can be freezed, so better to freeze it in onCreate (because usually it takes some time to start activity) than when a button clicked
Useless in browser JS, because there localStorage
uses as storage for data. (blocking and lightweight operation)
awaitLastCommit()
Required at application finish to await saving coroutine if it exists
Useless in infinity-running apps (or lifecycle-dependent) such as Android App, IOS app, Web server, JS Frontend.
I found it required only in colsole apps
It will be good if library create custom implementation of MutableList
instead of Storage.mutate
to improve experience of working with library.
This may be useful to extend from KFileDataStorage(file, json, scope), but it requires to split class with expect/actual
After a while library should be deployed to maven central, so anyone can import it without including maven.kotlingang.org
Priority is low since now it is not actual.
I don't know what is the return when there is no parent file, so I decided to put here a reduntant nullability modifier:
There are already some manual tests in json/json-files-jvm, but I should make a lot of "automated" tests
Add Storage.commit
and Storage.launchCommit
methods to save data after commit.
Library should be rewritten to provide more intuitive API without synchronization 'hacks' and with better functionality splitting
Due to bintray closing, there no way to implement this library now.
This may be useful to make integration with exposed or something like this
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.