I try to use A DataStore instance in compose multiplatform, for desktop
I share this here because i didn’t find anywhere else.
If you try to use DataStore in kotlin multiplatform you surely end there https://developer.android.com/kotlin/multiplatform/datastore
And because i misunderstoid it i’ll give the tips :
`/**
- Gets the singleton DataStore instance, creating it if necessary.
*/
fun createDataStore(producePath: () -> String): DataStore = PreferenceDataStoreFactory.createWithPath(
produceFile = { producePath().toPath() })`
This function doesn’t create a singleton, you have to handle that in a different variable, this create always a new datastore. In my opinion the comment above the function should be rewrite as “create a datastore instance”
Émile Levast is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.