Any recommendations for a light-weight (simple) KM...
# multiplatform
y
Any recommendations for a light-weight (simple) KMP library to persist ListT (a small list) and expose state changes via FlowT? Multiplatform-settings is great but does not provide observability for ListT. SQLDelight seems to heavy for such a simple task
c
y
The KMP version only supports Preferences DataStore tho, right? This would mean not supporting generic types
c
I don't know of any persisting library that supports generics. How would you know how to deserialize the type if you don't know the type?
y
JSON DataStore supports generics. The serializer is defined creation of the datastore.
Copy code
val Context.dataStore: DataStore<Settings> by dataStore(
    fileName = "settings.json",
    serializer = SettingsSerializer,
)
Would've been perfect but seems to be android only
c
No, that's what the preference datastore is also doing on KMP. It just does not support protobuf but plain json seialization.
y
Do you mean I can serialize T into String manually and store it? I cannot seem to find a functions that supports generics out of the box
c
yes, use kotlinx-serialization-json to serialize and deserialize your List<T>
🙏 1
p
Although the moment you persist a list, you'd likely start doing operations on it, and it becomes cumbersome to serialize/desirialize every time you do a query or mutation on the list. If you think sql is too heavy, consider a try to no-sql: https://github.com/jeffdgr8/kotbase
🙏 1