Hi. is DataStore available for KMM ? like I have used this library which uses shared pref and NSUSerDefaults for their native storage am not sure if we can do something like this using datastore ? Would I require to create my own native preference storage file which uses datastore and NSUserdefaults to store preference or is there any built in or third party available ?
Yeah I recently added DataStore support to Multiplatform Settings and would love to hear if it works for you. Only on the Android side though. For iOS you'd still use NSUserDefaults or the keychain
russhwolf
01/05/2021, 6:26 PM
I've done a tiny bit of experimenting with trying to port DataStore itself to multiplatform by converting its java/io usage to okio and it's new (not-yet-released) filesystem APIs, but nothing really fit for consumption there yet. Porting the tests is hard without a multiplatform kotlinx-coroutines-test and without that it's hard to confirm it's working as expected off the JVM.
m
Md Hanif
01/05/2021, 6:27 PM
does that mean I would need to seperately create different functions for storing the preferences in iOS ? like in the library I mentioned I just need to write
preference.setString()
and it has it's own predefined functions inside which uses NSUSerdefaults
Md Hanif
01/05/2021, 6:27 PM
@mbonnin thanks for the quick response.
r
russhwolf
01/05/2021, 6:28 PM
You'd need separate per-platform instantiation, but after that you can do everything from a common interface
👍 1
m
Md Hanif
01/05/2021, 6:30 PM
Okay great thanks for the quick response @russhwolf