https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
s

Sharyl

10/19/2023, 5:43 PM
Has anyone used MMKV for KMP? I am rewriting an old react native app into native. The db was done in the original react native app using MMKV. update: It was more about a seamless transition of the app to native by sticking with MMKV. I think I'll just scrap the idea. MMKV stands for Memory-map key-value storage and is commonly used for react native apps.
a

Alejandro Rios

10/19/2023, 5:57 PM
For a moment I thought MMKV was an architectural pattern 😂
🤣 2
p

Pablichjenkov

10/19/2023, 6:00 PM
Me too 🤣, I was like: "dang, another kid in town" 😂
🤣 1
c

Casey Brooks

10/19/2023, 6:12 PM
For key-value storage, Multiplatform-Settings is a good choice. It's not a new DB engine, but provides a common API over platform-specific storage https://github.com/russhwolf/multiplatform-settings
👆 1
👍 1
j

Jeff Lockhart

10/19/2023, 6:31 PM
My Couchbase Lite JSON document database KMP library also supports key/value, as well as SQL queries: https://github.com/jeffdgr8/kotbase I'll be publishing an initial public release soon with the Kotlin 1.9.20 release. (SNAPSHOT builds are available now.)
👍 2
❤️ 1
p

Pablichjenkov

10/19/2023, 9:11 PM
Hey Jeff, not associated with this question but does it support JS?
j

Jeff Lockhart

10/19/2023, 11:35 PM
No JS support currently @Pablichjenkov. Most other KMP targets are supported: Android, JVM, iOS, macOS, Linux, and Windows. I'm curious, what's your JS use case, web app or Node.js? Couchbase doesn't currently have a JS browser SDK. JS solutions are geared towards mobile JS apps. For Node.js they have an SDK for Couchbase Server, the backend database, but not Couchbase Lite. When I've looked into possibilities for web apps previously, WASM support at some point seems promising. Mostly it's proper filesystem and threading support that's needed first, which I believe WASM has to some degree on its roadmap. Then Couchbase Lite core C/C++ code could be built for WASM and I could add support in my KMP library.
p

Pablichjenkov

10/20/2023, 12:49 AM
I have checked the repo and haven’t seen the JS target that is what I ask. My target would be the web Apps on the browser. Just asking because I keep seeing this pattern for other libraries, realmdb for example is the same. I was checking a payment gateway the other way and the sdk for js was a bit off compared to Android and iOS. I got a couple of projects and all of them support the 4 platforms but code has started to get fragmented for the reason above. I will potentially start separating the mobile part out. In many third party libs, JS seems to be either missing or the API design is a bit different than mobile, which makes it harder to wrap. It is sad because it is really amazing seeing the same Composable component you build on Android running on the web. But yeah until something like wasm fully takes place in the browser, I believe we will be living with this mobile vs JS stuff.
r

russhwolf

10/20/2023, 3:01 AM
I’ve never worked with MMKV before, but if you think it would be useful to have it as a backing option for Multiplatform Settings, feel free to open a ticket on Github.
Looks like this also exists https://github.com/ctripcorp/mmkv-kotlin/
j

Jeff Lockhart

10/20/2023, 4:22 AM
@Pablichjenkov I understand. I'd love to be able to write once and have everything, including database, work the same on all platforms and the web. The persistence layer in the browser is one API surface that differs significantly from mobile/desktop apps. The threading model is another big difference. It seems WASM will address a lot of this eventually. SQLite is already running in the browser. It's quite possible Couchbase Lite could become available in the browser in the future. I think Kotlin still needs work to support full dependency interop for WASM as well though.
💯 1
p

Pablichjenkov

10/20/2023, 4:39 AM
It will be awesome but it will definitely take some time, no doubt about it.
s

Sharyl

10/23/2023, 6:09 PM
@russhwolf I've found that MMKV KMP wrapper already. I did not find it well enough supported to use in our app. We are rewriting a react-native app that is using MMKV. I was hoping to have seamless transition of persistent data when we replace the app(s) with native/KMP, but we have other changes in the system that aren't going to make that possible. So, it's no longer a necessity.
8 Views