Remove @ExperimentalCoroutinesApi from Database/Replicator extension functions to provide callback flows

It is already stable in 1.6.21.

@ExperimentalCoroutinesApi
fun Database.databaseChangeFlow(executor: Executor? = null) = callbackFlow<DatabaseChange> {
    val token = this@databaseChangeFlow.addChangeListener(executor) { trySend(it) }
    awaitClose { this@databaseChangeFlow.removeChangeListener(token) }
}

@ExperimentalCoroutinesApi
fun Database.documentChangeFlow(documentId: String, executor: Executor? = null) = callbackFlow {
    val token = this@documentChangeFlow.addDocumentChangeListener(documentId, executor) { trySend(it) }
    awaitClose { this@documentChangeFlow.removeChangeListener(token) }
}

@ExperimentalCoroutinesApi
fun Replicator.replicatorChangesFlow(executor: Executor? = null) = callbackFlow {
    val token = this@replicatorChangesFlow.addChangeListener(executor) { trySend(it) }
    awaitClose { this@replicatorChangesFlow.removeChangeListener(token) }
}

@ExperimentalCoroutinesApi
fun Replicator.documentReplicationFlow(executor: Executor? = null) = callbackFlow {
    val token = this@documentReplicationFlow.addDocumentReplicationListener(executor) { trySend(it) }
    awaitClose { this@documentReplicationFlow.removeChangeListener(token) }
}

@ExperimentalCoroutinesApi
fun Query.queryChangeFlow(executor: Executor? = null) = callbackFlow {
    val token = this@queryChangeFlow.addChangeListener(executor) { trySend(it) }
    awaitClose { this@queryChangeFlow.removeChangeListener(token) }
}

Hello,

Kotlin support was added in Couchbase Mobile 3.0 and supports back to Kolin 1.5 I believe, which is why these are marked as experimental. Our public beta for Couchbase Mobile 3.0 was released before 1.6 shipped, let alone 1.6.21. I’ll ping the SDK team with this feedback.

Thanks
Aaron

Aaron is correct. Those annotations will be removed in future releases.

1 Like