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

Theo

07/04/2020, 8:35 AM
does anyone have experience with Realm? I know there is an open ticket on realm-cocoa about supporting multiplatform projects somehow, how difficult would it be to write wrappers around realm-java and realm-cocoa for a kotlin multiplatform project, I'm stuck on how I would approach creating the Realm models... (currently I'm just handling the persistence outside of KMP, maybe this if fine for now until it's officially supported upstream)
s

streetsofboston

07/04/2020, 12:25 PM
If it's persistence you're looking for, not necessarily being Realm, consider using SqlDelight.
t

Theo

07/04/2020, 12:27 PM
Thanks! SqlDelight looks great. I'm mostly interested in the syncing services offered by realm, would love to use something like SqlDelight but I need some collaborative editing features and don't really want to implement a whole sync engine for that
m

Mgj

07/04/2020, 12:55 PM
If realm doesnt have any multiplatform support already, you'll probably have to define a common interface for realm-java and realm-cocoa yourself in your common code After that you use a facade pattern (either using
expect
/
actual
keywords or dependency injection), and you should be able to use it in your common code
t

Theo

07/04/2020, 1:08 PM
thanks a lot @Mgj, the put me in the right direction, I know they are working on it but not sure when that'l be released officially.
👍 1
m

Mgj

07/04/2020, 1:09 PM
For what its worth my plan is to use SqlDelight but yeah, i dont think it has the "auto-sync-with-cloud" features as Realm does
t

Theo

07/04/2020, 1:11 PM
I've gone down the road of "build your own offline-sync" feature before and while I learned a lot I wouldn't do it myself again 😂