Hi. is DataStore available for KMM ? like I have u...
# multiplatform
m
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 ?
m
You can look into https://github.com/russhwolf/multiplatform-settings, it looks like it supports DataStore
r
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
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
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
@mbonnin thanks for the quick response.
r
You'd need separate per-platform instantiation, but after that you can do everything from a common interface
👍 1
m
Okay great thanks for the quick response @russhwolf
318 Views