Differences from Java SDK
Kotbase's API aligns with the Couchbase Lite Java and Android KTX SDKs. Migrating existing Kotlin code can be
as straightforward as changing the import package from com.couchbase.lite to kotbase, with some exceptions:
- Java callback functional interfaces are implemented as Kotlin function types.
File,URL, andURIAPIs are represented as strings.DateAPIs use Kotlin'sInstant.InputStreamAPIs use kotlinx-io'sSource.ExecutorAPIs use Kotlin'sCoroutineContext.- Certificate APIs are available as raw
ByteArrays or in platform-specific code. - There's no need to explicitly call
CouchbaseLite.init(). Initialization functions can still be called with custom parameters in JVM and Android platform code. - Efforts have been made to detect and throw Kotlin exceptions for common error conditions, but
NSErrormay still leak through on Apple platforms. Please report any occurrences that may deserve addressing. - Some deprecated APIs are omitted.
- While not available in the Java SDK, as Java doesn't support operator overloading,
Fragmentsubscript APIs are available in Kotbase, similar to Swift, Objective-C, and .NET. - Configuration factory APIs from the Android KTX SDK have been deprecated in favor of using constructors directly, which support Kotlin named arguments themselves.