Quantcast
Channel: Mobile - Couchbase Forums
Viewing all articles
Browse latest Browse all 1117

Couchbase Lite for a Kotlin Multiplatform project

$
0
0

I’m evaluating Couchbase Lite for a project I’m building with Kotlin Multiplatform. The idea is to have most of the code in a pure Kotlin module and then build as little platform-specific code as possible to glue everything.

My target platforms are the JVM and Android, so I have an artifact for each: com.couchbase.lite:couchbase-lite-java and com.couchbase.lite:couchbase-lite-android-ktx. So far, so good.

The problem is that there is no common artifact both of them include, so even if 99% of my repository classes are the same in Android and in desktop (only the way to create a Database instance changes a bit, by needing the Android context and there are tiny changes in some factories), I’m forced, unless I’m overlooking something, to duplicate all my methods in both modules. It works, but it feels dirty. :slight_smile:

If I only had an artifact with interfaces for Database, MutableDocument, etc. that both the Android and the JVM library included transitively, I could include that one in my common module, implement there all the functionality and just leave the constructors themselves for the specific platforms.

Is there any other way you can think of achieving this code reuse? Is this something in the dev team backlog?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 1117

Trending Articles